#include <LedControl.h>
#define DATA_PIN 12
#define CLK_PIN 11
#define CS_PIN 10
#define NUM_CHIPS 1
#define ADDR 0
LedControl lc = LedControl(DATA_PIN, CLK_PIN, CS_PIN, NUM_CHIPS);
unsigned long data = 1;
void setup() {
lc.shutdown(0,false);
lc.setIntensity(0,8);
Serial.begin(9600);
}
void loop() {
//loadRandomDataIntoArray();
updatePots();
updateLed();
//delay(250);
//lc.clearDisplay(ADDR);
}
void updateLed(){
//write data to first 2 columns of the display
lc.setColumn(ADDR,0,data); //sets first column to first byte (LSB at bottom)
lc.setColumn(ADDR,1,data>>8); //sets next column to 2nd byte, (LSB at bottom)
}
void updatePots(){
int analogValue = analogRead(A0); //read input value
int scaledValue = map(analogValue,0,1023,0,15); //scales 10 bit input to 16 bits
data = 0; //clear data
bitSet(data, scaledValue); //set one bit only
}