Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //laboratorio 7
- //DIEGO LANDAZURY DIAZ
- //universidad santiago de cali
- // version:1.0
- #define PIN 3
- #define Pot A0// variables a utilizar
- const int Latch = 2;
- const int Clock = 3;
- const int Data = 4;
- int led[PIN] = {2,3,4}; // pines utilizados
- // valor de numeros a mostrar en el display
- int Numeros[10]={63,6,91,79,102,109,125,7,127,111};
- // Ciclo para activar los ocho pines como salida
- // y el pin A0 como entrada
- void setup() {
- for (int i=0; i<PIN; i++){
- pinMode(led[i], OUTPUT);
- }
- pinMode(Pot, INPUT);
- }
- void loop()
- {
- int Pos = analogRead(Pot); // lee la posicion del potenciometro
- int Mos = map(Pos, 0, 1023, 0,10); // realiza el mapeo
- Casos(Mos);
- }
- void Casos(int Valor)// elige un valor de acuerdo con la posicion del
- { // potenciometro
- switch(Valor)
- {
- case 0:
- On(Numeros[0]);
- break;
- case 1:
- On(Numeros[1]);
- break;
- case 2:
- On(Numeros[2]);
- break;
- case 3:
- On(Numeros[3]);
- break;
- case 4:
- On(Numeros[4]);
- break;
- case 5:
- On(Numeros[5]);
- break;
- case 6:
- On(Numeros[6]);
- break;
- case 7:
- On(Numeros[7]);
- break;
- case 8:
- On(Numeros[8]);
- break;
- case 9:
- On(Numeros[9]);
- break;
- }
- }
- void On(int Valor)// envia los datos alIntegrado
- {
- digitalWrite(Latch, LOW);
- shiftOut(Data, Clock, MSBFIRST, Valor);
- digitalWrite(Latch, HIGH);
- delay(8);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement