Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Apr 1st, 2020 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int sensorValue = 0;
  2. int leds[4] = {7, 8, 12, 13};
  3.  
  4. void setup()
  5. {
  6.   pinMode(A5, INPUT);
  7.   Serial.begin(9600);
  8.   for(int i = 0; i < 4; ++i) {
  9.     pinMode(leds[i], OUTPUT);
  10.   }
  11. }
  12.  
  13. void loop()
  14. {
  15.   sensorValue = analogRead(A5);
  16.   turnOnAll();
  17.   for(int i = 0; i < ledsToTurnOff(sensorValue); ++i) {
  18.     digitalWrite(leds[i], LOW);
  19.   }
  20.   delay(100);
  21. }
  22.  
  23. void turnOnAll() {
  24.   for(int i = 0; i < 4; ++i) {
  25.     digitalWrite(leds[i], HIGH);
  26.   }
  27. }
  28.  
  29. int ledsToTurnOff(int value) {
  30.   //przy zalozeniu, ze maksymalna wartosc z fotorezystora to 679
  31.   if(value < 136) return 0;
  32.   if(value < 272) return 1;
  33.   if(value < 408) return 2;
  34.   if(value < 544) return 3;
  35.   return 4;
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top