dumped all my old arduino stuff in here.
This commit is contained in:
parent
8cc6f23f59
commit
8f8959b76f
76 changed files with 8127 additions and 2 deletions
36
Dimmer/Dimmer.ino
Normal file
36
Dimmer/Dimmer.ino
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Dimmer
|
||||
* by David A. Mellis
|
||||
*
|
||||
* Demonstrates the sending data from the computer to the Arduino board,
|
||||
* in this case to control the brightness of an LED. The data is sent
|
||||
* in individual bytes, each of which ranges from 0 to 255. Arduino
|
||||
* reads these bytes and uses them to set the brightness of the LED.
|
||||
*
|
||||
* http://www.arduino.cc/en/Tutorial/Dimmer
|
||||
*/
|
||||
|
||||
int ledPin = 13;
|
||||
|
||||
void setup()
|
||||
{
|
||||
// begin the serial communication
|
||||
Serial.begin(9600);
|
||||
pinMode(ledPin, OUTPUT);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
byte val;
|
||||
|
||||
// check if data has been sent from the computer
|
||||
if (Serial.available()) {
|
||||
// read the most recent byte (which will be from 0 to 255)
|
||||
val = Serial.read();
|
||||
// set the brightness of the LED
|
||||
analogWrite(ledPin, val);
|
||||
//Serial.write(255);
|
||||
Serial.write(val/2);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue