Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int ledpin =11;
- int x;
- int y;
- int i;
- int z;
- bool ledstate = LOW;
- unsigned long previousmillis = 0;
- const long interval = 500;
- unsigned long currentmillis;
- void Blink(){
- ledstate=!ledstate;
- digitalWrite(ledpin, ledstate);
- }
- void setup() {
- // put your setup code here, to run once:
- Serial.begin(9600);
- pinMode(ledpin, OUTPUT);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- if (Serial.available()>0){
- x=Serial.read();
- if (x>=49){
- y=x-49;
- for (i=0; i>=y; i++){
- currentmillis = millis();
- z=currentmillis-previousmillis;
- if (z>=interval){
- Blink();}
- previousmillis=currentmillis;
- }}}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement