Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ********** Arduino **********
- * Laboratorio 10: Matriz LED 8x8 a través de IC MAX7219 dependiendo de Potenciómetro.
- * Autor: Cristian Augusto Restrepo
- * Descripción:
- * Controlar desde el Arduino, una matriz LED 8x8 a través de IC MAX7219,
- * para mostrar un número del 0 al 9, dependiendo de la posición del Potenciómetro.
- */
- #include "LedControlMS.h"
- //Antigua librería #include "LedControl.h"
- //Segmentos que se usan, datos seriales para estabecer cuando aparece que número
- //102.3 = 1, 204.6 = 2, 306.9 = 3, 409.9 = 4, 511.5 = 5,
- //613.8 = 6, 716.1 = 7, 818.4 = 8, 920.7 = 9, 1023 = 10
- #define NumMatrix 1
- //#define POT1 A0;
- int POT1 = A0;
- int DataPin = 9; //pin 9 conectado a DataIn
- int ClockPin = 10; //pin 10 conectado a CLK
- int LatchPIN = 8; //pin 8 conectado a LOAD/CS
- LedControl lc=LedControl(DataPin,ClockPin,LatchPIN,NumMatrix);
- void setup() {
- // initialize serial communication at 9600 bits per second:
- // // //Serial.begin(9600);
- for (int i=0; i< NumMatrix ; i++)
- {
- lc.shutdown(i,false); // Activar la matriz
- lc.setIntensity(i,1); // Poner el brillo a un valor intermedio
- lc.clearDisplay(i); // Y borrar todo
- }
- }
- // the loop routine runs over and over again forever:
- void loop() {
- // read the input on analog pin 0:
- int sensorValue = analogRead(A0);
- // print out the value you read:
- // // //Serial.println(sensorValue);
- //delay(1); // delay in between reads for stability
- if (sensorValue >= 0 && sensorValue <= 102.3){
- lc.writeString(0,"0");
- }
- if (sensorValue >= 102.40 && sensorValue <= 204.60){
- lc.writeString(0,"1");
- }
- if (sensorValue >= 204.61 && sensorValue <= 306.90){
- lc.writeString(0,"2");
- }
- if (sensorValue >= 306.91 && sensorValue <= 409.90){
- lc.writeString(0,"3");
- }
- if (sensorValue >= 409.91 && sensorValue <= 511.50){
- lc.writeString(0,"4");
- }
- if (sensorValue >= 511.51 && sensorValue <= 613.80){
- lc.writeString(0,"5");
- }
- if (sensorValue >= 613.81 && sensorValue <= 716.10){
- lc.writeString(0,"6");
- }
- if (sensorValue >= 716.11 && sensorValue <= 818.40){
- lc.writeString(0,"7");
- }
- if (sensorValue >= 818.41 && sensorValue <= 920.70){
- lc.writeString(0,"8");
- }
- if (sensorValue >= 920.71){
- lc.writeString(0,"9");
- }
- //delay(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment