96 lines
1.8 KiB
Plaintext
96 lines
1.8 KiB
Plaintext
/*
|
|
* 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 placa1 = 11;
|
|
int placa2 = 10;
|
|
int placa3 = 9;
|
|
int placa4 = 6;
|
|
int placa5 = 5;
|
|
int placa6 = 3;
|
|
int cont = 0;
|
|
int inc = 1;
|
|
|
|
void setup()
|
|
{
|
|
// begin the serial communication
|
|
Serial.begin(9600);
|
|
pinMode(placa1, OUTPUT);
|
|
pinMode(placa2, OUTPUT);
|
|
pinMode(placa3, OUTPUT);
|
|
pinMode(placa4, OUTPUT);
|
|
pinMode(placa5, OUTPUT);
|
|
pinMode(placa6, 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);
|
|
}
|
|
}
|
|
*/
|
|
|
|
//cont = cont + inc;
|
|
cont=200; //Solo para test
|
|
/*analogWrite(placa1, cont);
|
|
delay(1000);
|
|
analogWrite(placa2, cont);
|
|
delay(1000);
|
|
analogWrite(placa3, cont);
|
|
delay(1000);
|
|
analogWrite(placa4, cont);
|
|
delay(1000);
|
|
cont=0;
|
|
analogWrite(placa4, cont);
|
|
delay(1000);
|
|
analogWrite(placa3, cont);
|
|
delay(1000);
|
|
analogWrite(placa2, cont);
|
|
delay(1000);
|
|
analogWrite(placa1, cont);
|
|
delay(1000);*/
|
|
|
|
analogWrite(placa1, 0);
|
|
analogWrite(placa2, 0);
|
|
analogWrite(placa3, 0);
|
|
analogWrite(placa4, 0);
|
|
|
|
/*if(cont == 200){
|
|
//delay(2000);
|
|
inc = -1;
|
|
}
|
|
|
|
if(cont == 1){
|
|
delay(200);
|
|
inc = +1;
|
|
}
|
|
|
|
Serial.println(cont);
|
|
|
|
if(cont<11)
|
|
delay(120);
|
|
else if((cont<21)&&(cont>10))
|
|
delay(60);
|
|
else if((cont<81)&&(cont>20))
|
|
delay(30);
|
|
else if((cont<200)&&(cont>80))
|
|
delay(15);*/
|
|
|
|
}
|