228k views
3 votes
Write a program to create a square wave of 66% duty cycle on bit
3 of PORT C.

User Geier
by
8.6k points

1 Answer

1 vote

//main function

void setup() {

//pin17 is the bit 3 of port C on arduino.

pinMode(17, OUTPUT);

}

//loop

//we want to set this pin to either 5V or 0V.

//5V=high, 0V=low.

void loop() {

//square wave high value.

digitalWrite(17, HIGH);

//wait for 660.

delay(660);

//square wave low value.

digitalWrite(17, LOW);

//wait for 340.

delay(340);

}

User Ohad The Lad
by
8.5k points

No related questions found