Skip to content

Instantly share code, notes, and snippets.

@m4rk3r
Created March 28, 2018 03:08
Show Gist options
  • Save m4rk3r/b41a9c6b8710c87f3fa353cd9666278c to your computer and use it in GitHub Desktop.
Save m4rk3r/b41a9c6b8710c87f3fa353cd9666278c to your computer and use it in GitHub Desktop.
int pos = 155;
int M = 255;
int m = 155;
int dir = 1;
void setup(){
pinMode(9,OUTPUT);
Serial.begin(9600);
}
void loop(){
//if(pos%10==0)
analogWrite(9,pos);
delay(20);
pos += 1 * dir;
if(pos>=M)
dir = -1;
else if(pos <= m)
dir = 1;
Serial.println(pos);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment