Skip to content

Instantly share code, notes, and snippets.

@cpjobling
Last active August 10, 2023 09:16
Show Gist options
  • Save cpjobling/222597cccb0a98347184409b7034ac6a to your computer and use it in GitHub Desktop.
Save cpjobling/222597cccb0a98347184409b7034ac6a to your computer and use it in GitHub Desktop.
Experiment 3: Simple application of analogRead
// the setup function runs once when you press reset or power the board
word ADCval = 0;
void setup() {
// initialize Ports B and C pins 0-5 as outputs.
DDRB = 0b00111111;
DDRC = 0b00111111;
PORTB = 0; // both ports start from zero
PORTC = 0;
}
// the loop function runs over and over again forever
void loop() {
PORTC = (analogRead(A6)) / 16; // and that’s the active bit of the programme!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment