Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define MAXLED 3
- int led[MAXLED] = {9,10,11};
- int valor = 0;
- int i = 0;
- void setup()
- {
- Serial.begin(9600);
- for(int i = 0; i < MAXLED ; i++)
- {
- pinMode(led[i], OUTPUT);
- }
- }
- void loop()
- {
- if(Serial.available() > 0)
- {
- valor = Serial.read();
- if(valor == 'R')
- i = 0;
- if(valor == 'G')
- i = 1;
- if(valor == 'B')
- i = 2;
- valor = Serial.parseInt();
- analogWrite(led[i], valor);
- }
Advertisement
Add Comment
Please, Sign In to add comment