Steve;
Here is a simple example of turning on and off the first and last I/O bits of the extended bits that the Seeeduino Mega makes avalible.
[code]/*
- Toggle extended I/O bits 70 and 86 on and off for Seeeduino Mega board
- Also added an example of a digital input reading the state of digital pin 71
*/
int switchstate; // variable to hold value of digital input pin 70
void setup() // run once, when the sketch starts
{
DDRH |= 0x04; // sets the digital pin 70 to output, pin 70 is bit 2 of port H
DDRE |= 0x04; // sets the digital pin 86 to output, pin 86 is bit 2 of port E
DDRH &= 0x7f; // sets the digital pin 71 to input, pin 71 is bit 7 of port H
}
void loop() // run over and over again
{
PORTH |= 0x04; // sets pin 70 high
PORTE |= 0x04; // sets pin 86 high
delay(1000); // waits for a second
PORTH &= 0xfb; // sets pin 70 low
PORTE &= 0xfb; // sets pin 86 low
delay(1000); // waits for a second
switchstate = PINH & 0x80; // switchstate is non zero if digital input 71 is high, else it’s zero if input 71 is low
}
[/code]
Lefty