Projekt przygotowany przez Bee Project (Thailand)
Aplikacja na androida
kod:
//przypisujemy piny do RGB
const int redPin = 6;
const int greenPin = 5;
const int bluePin = 3;
#define REDPIN 6
#define GREENPIN 5
#define BLUEPIN 3
#define FADESPEED 5
void setup() {
// initialize serial:
Serial.begin(9600);
// make the pins outputs:
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
Serial.print("Arduino control RGB LEDs Connected OK ( Sent From Arduinno Board )");
Serial.print('\n');
}
void loop() {
// if there's any serial available, read it:
while (Serial.available() > 0) {
// look for the next valid integer in the incoming serial stream:
int red = Serial.parseInt();
// do it again:
int green = Serial.parseInt();
// do it again:
int blue = Serial.parseInt();
// look for the newline. That's the end of your
// sentence:
if (Serial.read() == '\n') {
// constrain the values to 0 - 255 and invert
// if you're using a common-cathode LED, just use "constrain(color, 0, 255);"
red = constrain(red, 0, 255);
green = constrain(green, 0, 255);
blue = constrain(blue, 0, 255);
// fade the red, green, and blue legs of the LED:
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
// print the three numbers in one string as hexadecimal:
Serial.print("Data Response : ");
Serial.print(red, HEX);
Serial.print(green, HEX);
Serial.println(blue, HEX);
}
}
}
W tym blogu można znaleźć kilka ciekawych... przynajmniej tak myślę projektów z wykorzystaniem ARDUINO. Wszystkie projekty są z pewnością zainspirowane znaleziskami w sieci, niemniej jednak są zrobione i sprawdzone.
piątek, 21 marca 2014
Zabawa RGB z telefonem w systemie android
robot, robotyka, arduino, projekty, budowa
android,
led,
projekt arduino,
rgb,
smarfon
niedziela, 2 marca 2014
Zabawa LEDami
Po wielu latach bezczynności udało się odpalić projekt Arduino ponownie... I trzeba się zacząć uczyć ponownie... To co mnie miło zaskoczyło to że jak tym razem zainstalowałem oprogramowanie Arduino to od razu wszystko zadziałało.
Któregoś dnia wykasowałem z googla+ przypadkowo wszystkie grafiki z bloga, przez co nie ma ich przy projektach... powoli je uzupełniam robiąc projekty na nowo. W końcu należy sobie wszystko przypomnieć.
W ramach przypomnienia zrobiłem sobie mały projekt z 10 LEDami i sobie le powłączałem i powyłączałem w różnych kombinacjach, poniżej kod... Zastanawiałem się czy nie można by go uprościć, np zrobić void on i off a potrm tylko on(1) zmienna z żarówką, którą chciałbym włączyć czy wyłączyć... może ktoś ma pomysł jak skrócić kod...
const int ledCount = 10;
int ledPins[] = { 4, 5, 6, 7, 8, 9,10,11,12,13 };
void setup() {
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
pinMode(ledPins[thisLed], OUTPUT);
}
}
void loop()
{
on1(); on2(); on3(); on4(); on5(); on6(); on7(); on8(); on9(); on10();
delay(500);
off1(); off2(); off3(); off4(); off5(); off6(); off7(); off8(); off9(); off10();
delay(500);
on1(); on2(); on3(); on4(); on5(); on6(); on7(); on8(); on9(); on10();
delay(500);
off1(); off2(); off3(); off4(); off5(); off6(); off7(); off8(); off9(); off10();
delay(1000);
on1(); delay(100); on2(); delay(100); on3(); delay(100); on4(); delay(100); on5(); delay(100); on6(); delay(100); on7(); delay(100); on8(); delay(100); on9(); delay(100); on10();delay(100);
off1(); delay(100); off2(); delay(100); off3(); delay(100); off4(); delay(100); off5(); delay(100); off6(); delay(100); off7(); delay(100); off8(); delay(100); off9(); delay(100); off10();
delay(100);
on1(); delay(100); on2(); delay(100); on3(); delay(100); on4(); delay(100); on5(); delay(100); on6(); delay(100); on7(); delay(100); on8(); delay(100); on9(); delay(100); on10();delay(100);
off1(); delay(100); off2(); delay(100); off3(); delay(100); off4(); delay(100); off5(); delay(100); off6(); delay(100); off7(); delay(100); off8(); delay(100); off9(); delay(100); off10();
delay(1000);
on1(); delay(100); off1(); on2(); delay(100); off2(); on3(); delay(100); off3(); on4(); delay(100); off4(); on5(); delay(100); off5(); on6(); delay(100); off6(); on7(); delay(100); off7(); on8(); delay(100); off8(); on9(); delay(100); off9(); on10(); delay(100); off10();
delay(100);
on10(); delay(100); off10(); on9(); delay(100); off9(); on8(); delay(100); off8(); on7(); delay(100); off7(); on6(); delay(100); off6(); on5(); delay(100); off5(); on4(); delay(100); off4(); on3(); delay(100); off3(); on2(); delay(100); off2(); on1(); delay(100); off1();
delay(100);
on1(); delay(100); off1(); on2(); delay(100); off2(); on3(); delay(100); off3(); on4(); delay(100); off4(); on5(); delay(100); off5(); on6(); delay(100); off6(); on7(); delay(100); off7(); on8(); delay(100); off8(); on9(); delay(100); off9(); on10(); delay(100); off10();
delay(100);
on10(); delay(100); off10(); on9(); delay(100); off9(); on8(); delay(100); off8(); on7(); delay(100); off7(); on6(); delay(100); off6(); on5(); delay(100); off5(); on4(); delay(100); off4(); on3(); delay(100); off3(); on2(); delay(100); off2(); on1(); delay(100); off1();
delay(1000);
on1(); on10(); delay(100); on2(); on9(); off1(); off10(); delay(100); on3(); on8(); off2(); off9(); delay(100); on4(); on7(); off3(); off8(); delay(100); on5(); on6(); off4(); off7(); delay(100); off5(); off6(); delay(100);on5(); on6(); delay(100); on4(); on7(); off5(); off6(); delay(100); on3(); on8(); off4(); off7(); delay(100); on2(); on9(); off3(); off8(); delay(100); on1(); on10(); off2(); off9(); delay(100); off1(); off10();
delay(100);
on1(); on10(); delay(100); on2(); on9(); off1(); off10(); delay(100); on3(); on8(); off2(); off9(); delay(100); on4(); on7(); off3(); off8(); delay(100); on5(); on6(); off4(); off7(); delay(100); off5(); off6(); delay(100);on5(); on6(); delay(100); on4(); on7(); off5(); off6(); delay(100); on3(); on8(); off4(); off7(); delay(100); on2(); on9(); off3(); off8(); delay(100); on1(); on10(); off2(); off9(); delay(100); off1(); off10();
delay(1000);
}
void on1(){ digitalWrite( 4, HIGH); }
void on2(){ digitalWrite( 5, HIGH); }
void on3(){ digitalWrite( 6, HIGH); }
void on4(){ digitalWrite( 7, HIGH); }
void on5(){ digitalWrite( 8, HIGH); }
void on6(){ digitalWrite( 9, HIGH); }
void on7(){ digitalWrite(10, HIGH); }
void on8(){ digitalWrite(11, HIGH); }
void on9(){ digitalWrite(12, HIGH); }
void on10(){ digitalWrite(13, HIGH); }
void off1(){ digitalWrite( 4, LOW); }
void off2(){ digitalWrite( 5, LOW); }
void off3(){ digitalWrite( 6, LOW); }
void off4(){ digitalWrite( 7, LOW); }
void off5(){ digitalWrite( 8, LOW); }
void off6(){ digitalWrite( 9, LOW); }
void off7(){ digitalWrite(10, LOW); }
void off8(){ digitalWrite(11, LOW); }
void off9(){ digitalWrite(12, LOW); }
void off10(){ digitalWrite(13, LOW); }
int ledPins[] = { 4, 5, 6, 7, 8, 9,10,11,12,13 };
void setup() {
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
pinMode(ledPins[thisLed], OUTPUT);
}
}
void loop()
{
on1(); on2(); on3(); on4(); on5(); on6(); on7(); on8(); on9(); on10();
delay(500);
off1(); off2(); off3(); off4(); off5(); off6(); off7(); off8(); off9(); off10();
delay(500);
on1(); on2(); on3(); on4(); on5(); on6(); on7(); on8(); on9(); on10();
delay(500);
off1(); off2(); off3(); off4(); off5(); off6(); off7(); off8(); off9(); off10();
delay(1000);
on1(); delay(100); on2(); delay(100); on3(); delay(100); on4(); delay(100); on5(); delay(100); on6(); delay(100); on7(); delay(100); on8(); delay(100); on9(); delay(100); on10();delay(100);
off1(); delay(100); off2(); delay(100); off3(); delay(100); off4(); delay(100); off5(); delay(100); off6(); delay(100); off7(); delay(100); off8(); delay(100); off9(); delay(100); off10();
delay(100);
on1(); delay(100); on2(); delay(100); on3(); delay(100); on4(); delay(100); on5(); delay(100); on6(); delay(100); on7(); delay(100); on8(); delay(100); on9(); delay(100); on10();delay(100);
off1(); delay(100); off2(); delay(100); off3(); delay(100); off4(); delay(100); off5(); delay(100); off6(); delay(100); off7(); delay(100); off8(); delay(100); off9(); delay(100); off10();
delay(1000);
on1(); delay(100); off1(); on2(); delay(100); off2(); on3(); delay(100); off3(); on4(); delay(100); off4(); on5(); delay(100); off5(); on6(); delay(100); off6(); on7(); delay(100); off7(); on8(); delay(100); off8(); on9(); delay(100); off9(); on10(); delay(100); off10();
delay(100);
on10(); delay(100); off10(); on9(); delay(100); off9(); on8(); delay(100); off8(); on7(); delay(100); off7(); on6(); delay(100); off6(); on5(); delay(100); off5(); on4(); delay(100); off4(); on3(); delay(100); off3(); on2(); delay(100); off2(); on1(); delay(100); off1();
delay(100);
on1(); delay(100); off1(); on2(); delay(100); off2(); on3(); delay(100); off3(); on4(); delay(100); off4(); on5(); delay(100); off5(); on6(); delay(100); off6(); on7(); delay(100); off7(); on8(); delay(100); off8(); on9(); delay(100); off9(); on10(); delay(100); off10();
delay(100);
on10(); delay(100); off10(); on9(); delay(100); off9(); on8(); delay(100); off8(); on7(); delay(100); off7(); on6(); delay(100); off6(); on5(); delay(100); off5(); on4(); delay(100); off4(); on3(); delay(100); off3(); on2(); delay(100); off2(); on1(); delay(100); off1();
delay(1000);
on1(); on10(); delay(100); on2(); on9(); off1(); off10(); delay(100); on3(); on8(); off2(); off9(); delay(100); on4(); on7(); off3(); off8(); delay(100); on5(); on6(); off4(); off7(); delay(100); off5(); off6(); delay(100);on5(); on6(); delay(100); on4(); on7(); off5(); off6(); delay(100); on3(); on8(); off4(); off7(); delay(100); on2(); on9(); off3(); off8(); delay(100); on1(); on10(); off2(); off9(); delay(100); off1(); off10();
delay(100);
on1(); on10(); delay(100); on2(); on9(); off1(); off10(); delay(100); on3(); on8(); off2(); off9(); delay(100); on4(); on7(); off3(); off8(); delay(100); on5(); on6(); off4(); off7(); delay(100); off5(); off6(); delay(100);on5(); on6(); delay(100); on4(); on7(); off5(); off6(); delay(100); on3(); on8(); off4(); off7(); delay(100); on2(); on9(); off3(); off8(); delay(100); on1(); on10(); off2(); off9(); delay(100); off1(); off10();
delay(1000);
}
void on1(){ digitalWrite( 4, HIGH); }
void on2(){ digitalWrite( 5, HIGH); }
void on3(){ digitalWrite( 6, HIGH); }
void on4(){ digitalWrite( 7, HIGH); }
void on5(){ digitalWrite( 8, HIGH); }
void on6(){ digitalWrite( 9, HIGH); }
void on7(){ digitalWrite(10, HIGH); }
void on8(){ digitalWrite(11, HIGH); }
void on9(){ digitalWrite(12, HIGH); }
void on10(){ digitalWrite(13, HIGH); }
void off1(){ digitalWrite( 4, LOW); }
void off2(){ digitalWrite( 5, LOW); }
void off3(){ digitalWrite( 6, LOW); }
void off4(){ digitalWrite( 7, LOW); }
void off5(){ digitalWrite( 8, LOW); }
void off6(){ digitalWrite( 9, LOW); }
void off7(){ digitalWrite(10, LOW); }
void off8(){ digitalWrite(11, LOW); }
void off9(){ digitalWrite(12, LOW); }
void off10(){ digitalWrite(13, LOW); }
robot, robotyka, arduino, projekty, budowa
10 led,
arduino,
led,
projekt arduino
Subskrybuj:
Posty (Atom)