Hardware 20
Hardware
Notice that things without quotations have to be variables, while things with them will just be printed as
words or text. The backslash chracter tells the microcontroller it is a special character such as tab, new line, or
another thing (see this table: http://msdn.microsoft.com/en-us/library/h21280bw%28v=vs.80%29.
aspx although not all of these are implemented in Galileo).
You can see these, by opening up tools->Serial Monitor (Lesson 3, Figure 5), after uploading a program with
serial stu onto the Galileo. (Remember to put some delay in your loop or you’ll back up the serial buer.) In
other words, you want to get the microcontroller to display values.
Lesson 3, Figure 5
For my program I wanted to see the read analog value, and the value I was putting out, so I changed the
program around a bit:
voidsetup(){
Serial.begin(9600);//setupserial
pinMode(A0,INPUT);//analogsensor
pinMode(3,OUTPUT);//ledindicator
}
voidloop(){
intreadValue;//valuereadfromsensor
intwrittenValue;//valuewrittentoled
readValue=analogRead(A0);//readthevaluefromtheanalog
sensor
writtenValue=map(readValue,200,1000,0,255);//The200
andthe1000arefromobservingtherangeofvaluesfrommysensor
//continuedonnextpage------->