SLIDE 33 Digital IO Examples
Turn a LED on and off Read a push button switch Drive and read a 4 x 4 keypad pinMode(8, OUTPUT); digitalWrite(8, 1); pinMode(5, INPUT_PULLUP); sw = digitalRead(5);
pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, INPUT_PULLUP); pinMode(9, INPUT_PULLUP); pinMode(10, INPUT_PULLUP); pinMode(11, INPUT_PULLUP); PORTD = 0xf0; val = PINB & 0x0f;
3 examples of using digital IO Turn on an LED – make the pin an output and write a 1 to the pin Read a switch – make the pin an input with a pull up and read the pin Driving and reading a 4 x 4 keypad, 16 buttons – can be done but too complicated for the simple Arduino functions – time to switch to C 31