GMU:Speculative Atmospheres II/Cosmo Niklas Schüppel: Difference between revisions

From Medien Wiki
Line 30: Line 30:
== the arduino code that I am using: ==
== the arduino code that I am using: ==


// a place to hold pin values
int x = 0;                     


int x = 0;                              // a place to hold pin values
//int ledpin = 13;


void setup()
void setup()
{
{
   Serial.begin(115200);              // 115200 is the default Arduino Bluetooth speed
   Serial.begin(115200);               
  digitalWrite(13,HIGH);              ///startup blink
   delay(600);
   delay(600);
   digitalWrite(13,LOW);
   digitalWrite(13,LOW);
Line 45: Line 43:




// Check serial buffer for characters
// If an 'r' is received then read the pins
// Read and send analog pins 0-5


void loop()
void loop()
{  
{  


if (Serial.available() > 0){        // Check serial buffer for characters
if (Serial.available() > 0){         
          
          
     if (Serial.read() == 'r') {      // If an 'r' is received then read the pins
     if (Serial.read() == 'r') {       
      
      
for (int pin= 0; pin<=5; pin++){      // Read and send analog pins 0-5
for (int pin= 0; pin<=5; pin++){       
     x = analogRead(pin);
     x = analogRead(pin);
     sendValue (x);
     sendValue (x);
Line 59: Line 60:
      
      


// Read and send digital pins 2-13
// Send a carriage returnt to mark end of pin data.
// add a delay to prevent crashing/overloading of the serial port


 
for (int pin= 2; pin<=13; pin++){     
for (int pin= 2; pin<=13; pin++){    // Read and send digital pins 2-13
     x = digitalRead(pin);
     x = digitalRead(pin);
     sendValue (x);
     sendValue (x);
     }
     }
    
    
     Serial.println();                // Send a carriage returnt to mark end of pin data.
     Serial.println();                 
     delay (5);                        // add a delay to prevent crashing/overloading of the serial port
     delay (5);                         
    
    
   }
   }
Line 74: Line 77:
}
}


void sendValue (int x){              // function to send the pin value followed by a "space".  
// function to send the pin value followed by a "space".  
 
void sendValue (int x){           
  Serial.print(x);
  Serial.print(x);
  Serial.write(32);
  Serial.write(32);
}
}