As computing becomes more ubiquitous in our objects, designers need to be more aware of how to design meaningful interactions into electronically enhanced objects. At the University of Washington, a class of junior Interaction Design majors is exploring this question. These pages chronicle their efforts.

Monday, April 29, 2013

AnalogRead Serial.print and light sensors


For this portion I was taking the components we were looking at in class and adding elements of the serial reading and printing in order to get a sense of what was going on behind the scenes. Did run into a problem where the data was scrolling side ways but it turned out that I needed to add a Serial.println(); which would start a new line.

Being able to see the read out helped me adjust the value so I got the best range for the LED which was One fourth of the analog readout.





code below


/*
  Blink
 Turns on an LED on for one second, then off for one second, repeatedly.

 This example code is in the public domain.
 */
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int sensorPin = A0;
int ledPin = 9;
int sensorValue = 0;
// the setup routine runs once when you press reset:
void setup() {              
  // initialize the digital pin as an output.
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600); // starts communication with computer
}
// the loop routine runs over and over again forever:
void loop() {
  sensorValue = analogRead(sensorPin);
  analogWrite(ledPin, sensorValue/4 );
  Serial.print("sensor = " );                     
  Serial.print(sensorValue/4);    
  Serial.println();

}

No comments:

Post a Comment