I really need help with this code. it compile without error but i upload it, it just wont work.
what am i doing wrong?
#include <Keypad.h>
#include <FastLED.h>
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
int keyindex;
const int arrsize = 12;
int i;
char sample[arrsize] = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '*', '#'};
char potnumber[arrsize] = {'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z'};
bool potplayed = false;
bool score = false;
#define NUM_LEDS 12
#define DATA_PIN 10 // we will figure this out during connection
CRGB leds[NUM_LEDS];
int tiltSensor = 11; // we will figure this out during connection
int tiltLed = 9; // we will figure this out during connection
int vibeSensor = 15; // we will figure this out during connection
int proxySensor = 16; // we will figure this out during connectio
void setup() {
Serial.begin(9600);
FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
pinMode(tiltSensor, INPUT);
pinMode(vibeSensor, INPUT);
pinMode(proxySensor, INPUT);
pinMode(tiltLed, OUTPUT);
}
void loop() {
char key = keypad.getKey();
Serial.print(key);
if(key != NO_KEY){
for(i=0; i< arrsize; i++){
if (key == sample[i]){
i = keyindex;
keyindex = keyindex;
Serial.print( " and the index is " );
Serial.print(keyindex);
}
if(key == potnumber[keyindex]){
potplayed = true;
Serial.println("Pot is used, try another pot");
leds[keyindex] = CRGB::Red;
FastLED.show();
// do other stuff like buzzer or turn Pot LED red
//delay(5000);
leds[keyindex] = CRGB::Black;
FastLED.show();
}else
if(potplayed = false){
potnumber[keyindex] = key;
// do other stuff like led light
if (digitalRead(tiltSensor) == HIGH) {
digitalWrite(tiltLed, HIGH);
leds[keyindex] = CRGB::Blue;
FastLED.show();
//delay(5000);
}else if(digitalRead(tiltSensor) == LOW){
digitalWrite(tiltLed, LOW);
leds[keyindex] = CRGB::Black;
FastLED.show();
}
if((digitalRead(tiltSensor) == HIGH) && (digitalRead(vibeSensor) == HIGH)){
if (digitalRead (proxySensor == HIGH)){
score = true;
leds[keyindex] = CRGB::Green;
FastLED.show();
}
}
if((digitalRead(tiltSensor) == LOW) && (digitalRead(vibeSensor) == HIGH)){
if (digitalRead (proxySensor == HIGH)){
score = true;
leds[keyindex] = CRGB::Green;
FastLED.show();
}
}
if((digitalRead(tiltSensor) == LOW) && (digitalRead(vibeSensor) == HIGH)){
if (digitalRead (proxySensor == LOW)){
score = false;
leds[keyindex] = CRGB::Black;
FastLED.show();
}
}
}
}
}
}