code to turn on pull-up
void setup(){
pinMode(3, INPUT);
digitalWrite(3,HIGH);}
void loop(){
int digin = digitalRead(3);
}Arduino Serial
Serial transmission is one bit sent at a time. Serial speeds can range from 9.6k to 115.2k, but for practical reasons we mostly use 57.6k. That is the same speed as good old dial-up tinternets.
Impratical example of code*
void setup(){Serial.begin(57600);}void loop(){Serial.print(1);delay (500);}
This will print out the ASCII value for one every half second. This in and of itself is utterly useless, unless something is listening on the computer and knows what to do with that 49. so instead of worrying about the encoding values, we can get Serial.print to pass information as is. We do this by adding in the argument BYTE. Thus the new code would look like "Serial.print(1, BYTE);"
Sample Lab Test Question;
Build a light controlled oscillator using a Light Dependant Resistor, a potential divider, arduino and MaxMSP.
Solution:
No comments:
Post a Comment