Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- long xpto = 0;
- long macaco = 0;
- long Ton = 750; // 10 a 750
- long Toff = 120; // 10 a 120
- byte Ligado = 0;
- //----------------------------------------
- void setup()
- {
- Serial.begin(9600);
- pinMode(13,OUTPUT);
- }
- //----------------------------------------
- void loop()
- {
- while (Ligado == 1)
- {
- if ((micros() - xpto) >Ton)
- {
- digitalWrite(13,HIGH);
- //Serial.println((micros() - xpto));
- Ligado = 0;
- macaco = micros();
- }
- }
- while (Ligado == 0)
- {
- if ((micros() - macaco) >Toff)
- {
- digitalWrite(13,LOW);
- //Serial.println((micros() - macaco));
- Ligado = 1;
- xpto = micros();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement