Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int led =11;
- int intensidad =255;
- void setup()
- {
- Serial.begin (9600);
- pinMode (led, OUTPUT);
- }
- void loop()
- {
- int valor;
- if (Serial.available() > 0)
- {
- valor =Serial.read();
- switch (valor)
- {
- case 1: onled(); break;
- case 2: offled(); break;
- case 3: addled(); break;
- case 4: quitled(); break;
- }
- }
- }
- void onled()
- {
- analogWrite (led, intensidad);
- }
- void offled()
- {
- analogWrite (led, 0);
- }
- void addled()
- {
- if (intensidad<255) intensidad=intensidad+25;
- onled();
- }
- void quitled()
- {
- if (intensidad>1) intensidad=intensidad-25;
- onled();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement