/usr/share/fritzing/sketches/core/Fritzing Creator Kit DE+EN/creator-kit-en/Fritzing Creator Kit/Potentiometer/Potentiometer.ino is in fritzing-data 0.9.3b+dfsg-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | /*
potentiometer
two LEDs are controlled by a potentiometer
This example is part of the Fritzing Creator Kit: www.fritzing.org/creator-kit.
*/
int ledGreen = 6; // LED pin is declared
int ledRed = 5; // LED pin is declared
int potPin = 0; // potentiometer pin is declared
void setup(){
// neither analog inputs nor outputs have to be declared in the setup
}
void loop(){
int value = analogRead(potPin); // this variable stores the value from the potentiometer
int redValue = map(value,0,1023,0,255); // mapped from a range of 0 to 1023 to a range of 0 to 255 for the red LED,
int greenValue = map(value,0,1023,255,0); // and for the green mapped to the reverse range from 255 to 0
analogWrite(ledRed,redValue); // the recalculated values are
analogWrite(ledGreen,greenValue); // send to the LEDs as analog values
}
|