Skip to content

Instantly share code, notes, and snippets.

@siddharthdeore
Created February 28, 2021 05:18
Show Gist options
  • Select an option

  • Save siddharthdeore/a9c955d23fb258dbdc628ec76ce72528 to your computer and use it in GitHub Desktop.

Select an option

Save siddharthdeore/a9c955d23fb258dbdc628ec76ce72528 to your computer and use it in GitHub Desktop.
Square wave generator for Anmol's Clock
void setup(){
DDRD = DDRD | B00000100; // Sets pin 2 as Output
}
void loop(){
while (1){
// Pin 2 High for 6ms
PORTD = PORTD | 0b00000100;
delayMicroseconds(6000);
// Pin 2 Low for 194ms
PORTD = PORTD & 0b11111011;
delayMicroseconds(194000);
// Total 200ms Duty Cycle
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment