Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const byte inputPotentiometer = 1;
- const byte inputSwitch = 8;
- const byte outputPWM = 5;
- const byte outputLed = 9;
- int fire;
- int pwm;
- int getPWMValue() {
- return map( analogRead( inputPotentiometer ), 0, 1023, 0, 255 );
- }
- void setup()
- {
- // Declaration des pin utilisée par la board
- pinMode( inputPotentiometer, INPUT );
- pinMode( inputSwitch, INPUT_PULLUP );
- pinMode( outputPWM, OUTPUT );
- pinMode( outputLed, OUTPUT );
- fire = 0;
- pwm = 0;
- }
- void loop()
- {
- pwm = getPWMValue();
- fire = digitalRead( inputSwitch );
- if ( fire == 1 ){
- digitalWrite( outputLed, LOW );
- analogWrite( outputPWM, 0 );
- }
- if (fire == 0){
- digitalWrite( outputLed, HIGH );
- analogWrite( outputPWM, pwm );
- } else {
- digitalWrite( outputLed, LOW );
- analogWrite( outputPWM, 0 );
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement