VOLTAGE LEVEL WITH SEVEN SEGMENT 74HC595

VOLTAGE LEVEL WITH SEVEN SEGMENT 74HC595

 

 

int latchPin = 8;

int clockPin = 12;

int dataPin = 11;

byte leds = 0;

const int sensorMin = 0; // sensor minimum, discovered through experiment

const int sensorMax = 1020;

void setup()

{

Serial.begin(9600);

pinMode(latchPin, OUTPUT);

pinMode(dataPin, OUTPUT);

pinMode(clockPin, OUTPUT);

}

void loop()

{

int sensorReading = analogRead(A0);

// map the sensor range to a range of four options:

int range = map(sensorReading, sensorMin, sensorMax, 0, 99);

Serial.println(sensorReading);

switch (range) {

case 0:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 192);

shiftOut(dataPin, clockPin, MSBFIRST, 255);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 1:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 249);

shiftOut(dataPin, clockPin, MSBFIRST, 255);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 2:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 164);

shiftOut(dataPin, clockPin, MSBFIRST, 255);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 3:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 176);

shiftOut(dataPin, clockPin, MSBFIRST, 255);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 4:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 153);

shiftOut(dataPin, clockPin, MSBFIRST, 255);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 5:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 146);

shiftOut(dataPin, clockPin, MSBFIRST, 255);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 6:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 130);

shiftOut(dataPin, clockPin, MSBFIRST, 255);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 7:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 248);

shiftOut(dataPin, clockPin, MSBFIRST, 255);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 8:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 128);

shiftOut(dataPin, clockPin, MSBFIRST, 255);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 9:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 144);

shiftOut(dataPin, clockPin, MSBFIRST, 255);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

///

case 10:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 192);

shiftOut(dataPin, clockPin, MSBFIRST, 249);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 11:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 249);

shiftOut(dataPin, clockPin, MSBFIRST, 249);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 12:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 164);

shiftOut(dataPin, clockPin, MSBFIRST, 249);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 13:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 176);

shiftOut(dataPin, clockPin, MSBFIRST, 249);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 14:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 153);

shiftOut(dataPin, clockPin, MSBFIRST, 249);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 15:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 146);

shiftOut(dataPin, clockPin, MSBFIRST, 249);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 16:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 130);

shiftOut(dataPin, clockPin, MSBFIRST, 249);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 17:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 248);

shiftOut(dataPin, clockPin, MSBFIRST, 249);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 18:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 128);

shiftOut(dataPin, clockPin, MSBFIRST, 249);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 19:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 144);

shiftOut(dataPin, clockPin, MSBFIRST, 249);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 20:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 192);

shiftOut(dataPin, clockPin, MSBFIRST, 164);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 21:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 249);

shiftOut(dataPin, clockPin, MSBFIRST, 164);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 22:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 164);

shiftOut(dataPin, clockPin, MSBFIRST, 164);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 23:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 176);

shiftOut(dataPin, clockPin, MSBFIRST, 164);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 24:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 153);

shiftOut(dataPin, clockPin, MSBFIRST, 164);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 25:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 146);

shiftOut(dataPin, clockPin, MSBFIRST, 164);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 26:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 130);

shiftOut(dataPin, clockPin, MSBFIRST, 164);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 27:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 248);

shiftOut(dataPin, clockPin, MSBFIRST, 164);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 28:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 128);

shiftOut(dataPin, clockPin, MSBFIRST, 164);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 29:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 144);

shiftOut(dataPin, clockPin, MSBFIRST, 164);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 30:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 192);

shiftOut(dataPin, clockPin, MSBFIRST, 176);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

//

case 31:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 249);

shiftOut(dataPin, clockPin, MSBFIRST, 176);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 32:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 164);

shiftOut(dataPin, clockPin, MSBFIRST, 176);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 33:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 176);

shiftOut(dataPin, clockPin, MSBFIRST, 176);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 34:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 153);

shiftOut(dataPin, clockPin, MSBFIRST, 176);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 35:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 146);

shiftOut(dataPin, clockPin, MSBFIRST, 176);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 36:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 130);

shiftOut(dataPin, clockPin, MSBFIRST, 176);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 37:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 248);

shiftOut(dataPin, clockPin, MSBFIRST, 176);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 38:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 128);

shiftOut(dataPin, clockPin, MSBFIRST, 176);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 39:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 144);

shiftOut(dataPin, clockPin, MSBFIRST, 176);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

//

case 40:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 192);

shiftOut(dataPin, clockPin, MSBFIRST, 153);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

//

case 41:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 249);

shiftOut(dataPin, clockPin, MSBFIRST, 153);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 42:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 164);

shiftOut(dataPin, clockPin, MSBFIRST, 153);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 43:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 176);

shiftOut(dataPin, clockPin, MSBFIRST, 153);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 44:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 153);

shiftOut(dataPin, clockPin, MSBFIRST, 153);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 45:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 146);

shiftOut(dataPin, clockPin, MSBFIRST, 153);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 46:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 130);

shiftOut(dataPin, clockPin, MSBFIRST, 153);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 47:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 248);

shiftOut(dataPin, clockPin, MSBFIRST, 153);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 48:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 128);

shiftOut(dataPin, clockPin, MSBFIRST, 153);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 49:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 144);

shiftOut(dataPin, clockPin, MSBFIRST, 153);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

//

case 50:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 192);

shiftOut(dataPin, clockPin, MSBFIRST, 146);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

//

case 51:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 249);

shiftOut(dataPin, clockPin, MSBFIRST, 146);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 52:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 164);

shiftOut(dataPin, clockPin, MSBFIRST, 146);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 53:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 176);

shiftOut(dataPin, clockPin, MSBFIRST, 146);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 54:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 153);

shiftOut(dataPin, clockPin, MSBFIRST, 146);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 55:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 146);

shiftOut(dataPin, clockPin, MSBFIRST, 146);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 56:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 130);

shiftOut(dataPin, clockPin, MSBFIRST, 146);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 57:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 248);

shiftOut(dataPin, clockPin, MSBFIRST, 146);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 58:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 128);

shiftOut(dataPin, clockPin, MSBFIRST, 146);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 59:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 144);

shiftOut(dataPin, clockPin, MSBFIRST, 146);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

//

case 60:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 192);

shiftOut(dataPin, clockPin, MSBFIRST, 130);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

//

case 61:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 249);

shiftOut(dataPin, clockPin, MSBFIRST, 130);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 62:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 164);

shiftOut(dataPin, clockPin, MSBFIRST, 130);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 63:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 176);

shiftOut(dataPin, clockPin, MSBFIRST, 130);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 64:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 153);

shiftOut(dataPin, clockPin, MSBFIRST, 130);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 65:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 146);

shiftOut(dataPin, clockPin, MSBFIRST, 130);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 66:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 130);

shiftOut(dataPin, clockPin, MSBFIRST, 130);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 67:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 248);

shiftOut(dataPin, clockPin, MSBFIRST, 130);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 68:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 128);

shiftOut(dataPin, clockPin, MSBFIRST, 130);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 69:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 144);

shiftOut(dataPin, clockPin, MSBFIRST, 130);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

//

case 70:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 192);

shiftOut(dataPin, clockPin, MSBFIRST, 248);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

//

case 71:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 249);

shiftOut(dataPin, clockPin, MSBFIRST, 248);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 72:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 164);

shiftOut(dataPin, clockPin, MSBFIRST, 248);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 73:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 176);

shiftOut(dataPin, clockPin, MSBFIRST, 248);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 74:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 153);

shiftOut(dataPin, clockPin, MSBFIRST, 248);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 75:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 146);

shiftOut(dataPin, clockPin, MSBFIRST, 248);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 76:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 130);

shiftOut(dataPin, clockPin, MSBFIRST, 248);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 77:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 248);

shiftOut(dataPin, clockPin, MSBFIRST, 248);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 78:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 128);

shiftOut(dataPin, clockPin, MSBFIRST, 248);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 79:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 144);

shiftOut(dataPin, clockPin, MSBFIRST, 248);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

//

case 80:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 192);

shiftOut(dataPin, clockPin, MSBFIRST, 128);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

//

case 81:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 249);

shiftOut(dataPin, clockPin, MSBFIRST, 128);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 82:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 164);

shiftOut(dataPin, clockPin, MSBFIRST, 128);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 83:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 176);

shiftOut(dataPin, clockPin, MSBFIRST, 128);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 84:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 153);

shiftOut(dataPin, clockPin, MSBFIRST, 128);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 85:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 146);

shiftOut(dataPin, clockPin, MSBFIRST, 128);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 86:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 130);

shiftOut(dataPin, clockPin, MSBFIRST, 128);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 87:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 248);

shiftOut(dataPin, clockPin, MSBFIRST, 128);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 88:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 128);

shiftOut(dataPin, clockPin, MSBFIRST, 128);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 89:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 144);

shiftOut(dataPin, clockPin, MSBFIRST, 128);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

//

case 90:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 192);

shiftOut(dataPin, clockPin, MSBFIRST, 144);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

//

case 91:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 249);

shiftOut(dataPin, clockPin, MSBFIRST, 144);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 92:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 164);

shiftOut(dataPin, clockPin, MSBFIRST, 144);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 93:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 176);

shiftOut(dataPin, clockPin, MSBFIRST, 144);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 94:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 153);

shiftOut(dataPin, clockPin, MSBFIRST, 144);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 95:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 146);

shiftOut(dataPin, clockPin, MSBFIRST, 144);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 96:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 130);

shiftOut(dataPin, clockPin, MSBFIRST, 144);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 97:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 248);

shiftOut(dataPin, clockPin, MSBFIRST, 144);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 98:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 128);

shiftOut(dataPin, clockPin, MSBFIRST, 144);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

case 99:

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 144);

shiftOut(dataPin, clockPin, MSBFIRST, 144);

//MSBFIRST is LED trigger from no 1

//LSBFIRST is LED trigger from no 8

digitalWrite(latchPin, HIGH);

break;

}

}

OTHER SKET==========================================

int latchPin = 8;

int clockPin = 12;

int dataPin = 11;

int first_digit;

int second_digit;

const int sensorMin = 0; // sensor minimum, discovered through experiment

const int sensorMax = 1020;

void setup()

{

Serial.begin(9600);

pinMode(latchPin, OUTPUT);

pinMode(dataPin, OUTPUT);

pinMode(clockPin, OUTPUT);

}

void loop()

{

int sensorReading = analogRead(A0);

// map the sensor range to a range of four options:

int range = map(sensorReading, sensorMin, sensorMax, 0, 99);

//Serial.println(range);

first_digit = range / 10;

second_digit = range – (first_digit * 10);

DisplayNum(second_digit);

DisplayNum(first_digit);

delay(1000);

}

void DisplayNum(int num)

{

if (num == 0) {

// Decimal 192 Binary output 11000000 Displays 0

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 192);

digitalWrite(latchPin, HIGH);

} else if (num == 1) {

// Decimal 6 Binary output 11111001 Displays 1

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 249);

digitalWrite(latchPin, HIGH);

} else if (num == 2) {

// Decimal 164 Binary output 10100100 Displays 2

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 164);

digitalWrite(latchPin, HIGH);

} else if (num == 3) {

// Decimal 176 Binary output 10110000 Displays 3

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 176);

digitalWrite(latchPin, HIGH);

} else if (num == 4) {

// Decimal 153 Binary output 10011001 Displays 4

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 153);

digitalWrite(latchPin, HIGH);

} else if (num == 5) {

// Decimal 146 Binary output 10010010 Displays 5

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 146);

digitalWrite(latchPin, HIGH);

} else if (num == 6) {

// Decimal 130 Binary output 10000010 Displays 6

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 130);

digitalWrite(latchPin, HIGH);

} else if (num == 7) {

// Decimal 248 Binary output 11111000 Displays 7

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 248);

digitalWrite(latchPin, HIGH);

} else if (num == 8) {

// Decimal 128 Binary output 10000000 Displays 8

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 128);

digitalWrite(latchPin, HIGH);

} else if (num == 9) {

// Decimal 144 Binary output 10011000 Displays 9

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 144);

digitalWrite(latchPin, HIGH);

}else {

// Decimal 255 Binary output 11111111 BLANK

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, MSBFIRST, 255);

digitalWrite(latchPin, HIGH);

}

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s