Return to Snippet

Revision: 65499
at December 8, 2013 23:41 by peacon_nut


Initial Code
void setup() 
{  
Serial.begin(57600); //sets speed at which data is read from Arduino.

analogReference(EXTERNAL); //sets Arduino board voltage reference to external input
pinMode(A0, OUTPUT); //sets A0 pin to output mode
pinMode(A1, OUTPUT); //sets A1 pin to output mode
digitalWrite(A0, HIGH); //A0 pin outputs reference voltage
digitalWrite(A1, LOW); //A1 acts as a ground (GRD) output.

pinMode(2,INPUT_PULLUP); //sets digital pin 2 to a known state when no input is present
pinMode(3,INPUT_PULLUP); //sets digital pin 3 to a known state when no input is present

}


void loop() //initiate loop
{
      
      int Result = analogRead(A3); //sets variable "Result" to be whatever is coming into A3 pin. In this case, it is the Y-axis of accelerometer.
      Serial.write (Result >> 7); 
      Serial.write (Result%128); 

      int Switch1 = digitalRead(2); //sets variable "Switch1" to whatever data is coming from digital pin 2
      Serial.write(Switch1); //sends "Switch1" data to serial port.
      
      int Switch2 = digitalRead(3); //sets variable "Switch2" to whatever data is coming from digital pin 3
      Serial.write(Switch2); //sends "Switch2" data to serial port.
      
      
      Serial.write(255); //sends the value 255 to signify the end of one round of the loop to the Max/MSP patch.
    
    
      delay(10); //delays the loop by 10 milliseconds        
}

Initial URL

                                

Initial Description
Final project for module Performance Technology 2.
Lecturer: Nick Ward

Initial Title
Arduino Code For "The Sensor Seat"

Initial Tags

                                

Initial Language
Processing