Tuesday, November 17, 2009

Week10

DMSS5 - Wk10


//**************************************************************************//
int analogData; // outgoing ADC value
int digitalPin;
int i; //used for the loop
byte x = 0; //byte to store digital status


void setup() {
//setup serial baudrate is set at the highest speed for USB connection
Serial.begin(57600);
//enable digital pullups. All digital pins are set high
//and will only output change when connected to ground
for(i=2;i<8;++i)>
{
digitalPin = i;
pinMode(digitalPin, INPUT);
digitalWrite(digitalPin, HIGH); //enable internal pullups
}
}

//Main Loop
void loop() { //read the digital pins in one go
x = PIND;
x = x >> 2; // Shift by 2 to avoid TX and RX pins
Serial.print(x, BYTE);

/* get analog in, for the number enabled */
analogData = analogRead(0); // Read current analog pin value
Serial.print(analogData >> 7, BYTE); // shift high bits into output byte
Serial.print(analogData % 128, BYTE); // mod by 128 for the small byte

analogData = analogRead(1); // Read current analog pin value
Serial.print(analogData >> 7, BYTE); // shift high bits into output byte
Serial.print(analogData % 128, BYTE); // mod by 128 for the small byte

Serial.print(255, BYTE); // end of digital signifier
delay(10);

}




No comments:

Post a Comment