first commit
This commit is contained in:
51
ESP01_COUPLE_ARDUINO/ESP01_COUPLE_ARDUINO.ino
Normal file
51
ESP01_COUPLE_ARDUINO/ESP01_COUPLE_ARDUINO.ino
Normal file
@@ -0,0 +1,51 @@
|
||||
#define RedLed 12
|
||||
#define GreenLed 13
|
||||
#define BlueLed 15
|
||||
int inByte;
|
||||
String sChaine = "";
|
||||
void setup() {
|
||||
pinMode(GreenLed, OUTPUT);
|
||||
pinMode(RedLed, OUTPUT);
|
||||
pinMode(BlueLed, OUTPUT);
|
||||
Serial.begin(9600);
|
||||
//-- Led Bleu = Init Ok
|
||||
setColor(0, 255, 0);
|
||||
}
|
||||
void loop() {
|
||||
if (Serial.available()) {
|
||||
delay(100);
|
||||
while (Serial.available()) {
|
||||
inByte = Serial.read();
|
||||
if ( inByte > 32 && inByte < 123)
|
||||
{
|
||||
sChaine += char(inByte);
|
||||
}
|
||||
}
|
||||
sChaine.trim();
|
||||
sChaine.toLowerCase();
|
||||
//-- Test de la commande
|
||||
if (sChaine.equals("rouge"))
|
||||
{
|
||||
setColor(0, 0, 255);
|
||||
Serial.println("rougeok");
|
||||
}
|
||||
else if (sChaine.equals("vert"))
|
||||
{ setColor(255, 0, 0);
|
||||
Serial.println("vertok");
|
||||
}
|
||||
else if (sChaine.equals("bleu"))
|
||||
{ setColor(0, 255, 0);
|
||||
Serial.println("bleuok");
|
||||
}
|
||||
else
|
||||
Serial.println(sChaine);
|
||||
sChaine = "";
|
||||
delay(100);
|
||||
}
|
||||
}
|
||||
void setColor(int red, int green, int blue)
|
||||
{
|
||||
analogWrite(RedLed, red);
|
||||
analogWrite(GreenLed, green);
|
||||
analogWrite(BlueLed, blue);
|
||||
}
|
||||
Reference in New Issue
Block a user