EasyManua.ls Logo

Intel Galileo - Galileo Disclaimer

Intel Galileo
34 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Hardware 19
Hardware
I changed the amount of light going to the photodiode to change the noise coming out the speaker. Play
around!
3.8: Using serial (optional)
If you have time or want to learn more about microcontrollers, the serial library is a good way to get more out
of your microcontroller.
In our analog sensor program, we assumed our sensor would go all the way from 0 to 1023. However, this is
generally not the case, sensors are often not as sensitive as we would like. In our program, we have no real
way of telling how sensitive it is, and our LED may not be lighting up as bright or dim as much as we really
want.
The serial library is a way to see the actual numbers the microcontroller is using, and to see exactly what it
is reading from the pin. This can also be helpful for seeing if the sensor isn’t working at all. The word serial
has to do with how the Galileo sends information back to the computer, which is via a serial port. A library is
a collection of code someone else has written, which makes our jobs easier.
The microcontroller needs to be told that we are using serial, which means we have to tell it to beginning in
setup:
scaledvalue=map(avalue,0,1024+1024,0,254);//Scaletheoutput
appropiately,Iguessedandcheckedtomakethesoundmoresensitive.
analogWrite(out,scaledvalue);//writethescaledvaluetotheoutput
pin
delay(map(avalue,0,1024+1024,0,100);
}
The number, 9600, tells the microcontroller the data rate of the serial, which has to be a certain number.
9600 should be the number you use, until you get into super-advanced microcontroller stu.
Then, we want to get information to print. In loop we can put commands such as:
Serial.print(“hello”);//printhello!
Serial.println(“hey”);//printheyand
startanewline
Serial.print(myVariable);//printthevalue
ofmyvariable
Serial.print(“\n”);//printanewline
voidsetup(){
Serial.begin(9600);
}

Other manuals for Intel Galileo

Related product manuals