50 lines
1.1 KiB
C++
50 lines
1.1 KiB
C++
/*
|
|
Mega analogWrite() test
|
|
|
|
This sketch fades LEDs up and down one at a time on digital pins 2 through 13.
|
|
This sketch was written for the Arduino Mega, and will not work on other boards.
|
|
|
|
The circuit:
|
|
- LEDs attached from pins 2 through 13 to ground.
|
|
|
|
created 8 Feb 2009
|
|
by Tom Igoe
|
|
|
|
This example code is in the public domain.
|
|
|
|
http://www.arduino.cc/en/Tutorial/AnalogWriteMega
|
|
*/
|
|
|
|
// These constants won't change. They're used to give names to the pins used:
|
|
const int Pin = 4;
|
|
const int Barra1 = 46;
|
|
const int Barra2 = 45;
|
|
|
|
|
|
void setup() {
|
|
pinMode(Pin, OUTPUT);
|
|
pinMode(Barra1, OUTPUT);
|
|
pinMode(Barra2, OUTPUT);
|
|
pinMode(47, OUTPUT);
|
|
digitalWrite(47, LOW);
|
|
analogWrite(Barra1, 255);
|
|
analogWrite(Barra2, 255);
|
|
|
|
}
|
|
|
|
void loop() {
|
|
|
|
// digitalWrite(47, HIGH);
|
|
// analogWrite(Barra2, map(10, 0, 100, 255, 0));
|
|
// delay(2000);
|
|
// digitalWrite(47, LOW);
|
|
// analogWrite(Barra2, map(0, 0, 100, 255, 0));
|
|
// delay(10000);
|
|
|
|
// analogWrite(Pin, 0);
|
|
// delay(1000);
|
|
//analogWrite(Pin, 255);
|
|
// delay(1000);
|
|
|
|
}
|