I am using an arduino uno, logic level converter, adafruit Bicolor LED Matrix, a Raspberry pi, and a button but am having some issues. My goal is that when the button is pushed on the pi it sends a signal to the arduino Uno which will change the animation on the LED backpack. The issue is that the button must be held down right when the loop restarts and if you click it any other time it wont work, I think this is because I am using delay() which pauses everything. Is there any way to pause without using delay()? I have heard of using Millis() but I am new to Arduino's and im not sure how I would implement it at all. Thanks in advance.
#include <Adafruit_LEDBackpack.h>
#include <Adafruit_GFX.h>
#include <Wire.h>
#include "blinky.h" // Animation for blinking and just chilling
#include "looking.h" // This one looks forward when it hears or speaks
Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix(); // We are using a bicolor Matrix
int piPin = 3;
char count = 0;
void setup() {
matrix.begin(0x70); // Turns on Matrix
Serial.begin(9600);
pinMode(piPin, INPUT); // Tells the pin that it's an input
}
void loop() {
int sense = digitalRead(piPin); //Reads the Pi pin
while(sense == HIGH){ count + 1;}
if(count >= 1) { //If the Raspberry Pi is sending input
matrix.clear();
matrix.drawBitmap(0, 0, looking_1, 8, 8, LED_YELLOW); // It will look forward
matrix.writeDisplay();
delay(3000);
matrix.clear();
matrix.drawBitmap(0, 0, looking_2, 8, 8, LED_YELLOW); // It will look forward
matrix.writeDisplay();
delay(200);
matrix.clear();
matrix.drawBitmap(0, 0, looking_3, 8, 8, LED_YELLOW); // It will look forward
matrix.writeDisplay();
delay(3000);
matrix.clear();
matrix.drawBitmap(0, 0, looking_2, 8, 8, LED_YELLOW); //Makes it look back
matrix.writeDisplay();
delay(2000);
count == 0;
} else {
matrix.clear();
matrix.drawBitmap(0, 0, blink_1, 8, 8, LED_GREEN); // It will just blink
matrix.writeDisplay();
delay(3000);
matrix.clear();
matrix.drawBitmap(0, 0, blink_2, 8, 8, LED_GREEN); // It will just blink
matrix.writeDisplay();
delay(100);
matrix.clear();
matrix.drawBitmap(0, 0, blink_3, 8, 8, LED_GREEN); // It will just blink
matrix.writeDisplay();
delay(100);
matrix.clear();
matrix.drawBitmap(0, 0, blink_4, 8, 8, LED_GREEN); // It will just blink
matrix.writeDisplay();
delay(100);
matrix.clear();
matrix.drawBitmap(0, 0, blink_5, 8, 8, LED_GREEN); // It will just blink
matrix.writeDisplay();
delay(100);
matrix.clear();
matrix.drawBitmap(0, 0, blink_6, 8, 8, LED_GREEN); // It will just blink
matrix.writeDisplay();
delay(100);
matrix.clear();
matrix.drawBitmap(0, 0, blink_7, 8, 8, LED_GREEN); // It will just blink
matrix.writeDisplay();
delay(100);
matrix.clear();
matrix.drawBitmap(0, 0, blink_8, 8, 8, LED_GREEN); // It will just blink
matrix.writeDisplay();
delay(100);
matrix.clear();
matrix.drawBitmap(0, 0, blink_9, 8, 8, LED_GREEN); // It will just blink
matrix.writeDisplay();
delay(100);
matrix.clear();
matrix.drawBitmap(0, 0, blink_8, 8, 8, LED_GREEN); // It will just blink
matrix.writeDisplay();
delay(100);
matrix.clear();
matrix.drawBitmap(0, 0, blink_7, 8, 8, LED_GREEN); // It will just blink
matrix.writeDisplay();
delay(100);
matrix.clear();
matrix.drawBitmap(0, 0, blink_6, 8, 8, LED_GREEN); // It will just blink
matrix.writeDisplay();
delay(100);
matrix.clear();
matrix.drawBitmap(0, 0, blink_5, 8, 8, LED_GREEN); // It will just blink
matrix.writeDisplay();
delay(100);
matrix.clear();
matrix.drawBitmap(0, 0, blink_4, 8, 8, LED_GREEN); // It will just blink
matrix.writeDisplay();
delay(100);
matrix.clear();
matrix.drawBitmap(0, 0, blink_3, 8, 8, LED_GREEN); // It will just blink
matrix.writeDisplay();
delay(100);
matrix.clear();
matrix.drawBitmap(0, 0, blink_2, 8, 8, LED_GREEN); // It will just blink
matrix.writeDisplay();
delay(100);
}
}