Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum led {
- VILLOG_KI,
- VILLOG_BE,
- LED_BE,
- LED_KI
- };
- enum led led_allapot;
- const int ledPin = 13;
- long sebesseg = 500;
- unsigned long ido_regi = 0;
- void setup() {
- pinMode(ledPin, OUTPUT);
- Serial.begin(9600);
- }
- void loop() {
- unsigned long ido = millis();
- if (Serial.available() > 0) {
- char kapcsolo = Serial.read();
- // turn off LED
- if (kapcsolo == '-')
- led_allapot = VILLOG_KI;
- // turn on LED
- if (kapcsolo == '+')
- led_allapot = VILLOG_BE;
- }
- if (led_allapot > VILLOG_KI) {
- if ((unsigned long)(ido - ido_regi >= sebesseg)) {
- if (led_allapot == LED_BE) {
- led_allapot = LED_KI;
- digitalWrite(ledPin, LOW);
- } else {
- led_allapot = LED_BE;
- digitalWrite(ledPin, HIGH);
- }
- ido_regi = ido;
- }
- } else if (led_allapot == VILLOG_KI) {
- digitalWrite(ledPin, LOW);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement