LCD display/capacitive sensors problem - how can I clear the LCD display?

Hi everyone,

I have a deadline for my assignment on Thursday morning and I am stuck on something that will probably seem very basic to you.

I am using 2 capacitive sensors and LCD display.

1 capacitive sensor turn the LEDs on in some kind of way. That works absolutely fine. I access them using arrays.

MY PROBLEM IS

  1. The LCD display never clears, so if I want the lights to do the same magic again, I’d have to hard-reset the arduino.
  2. My second capacitive sensor is wired correctly and it senses too. But I wanted to use this sensor to actually reverse what the first sensor does. Or at least just clear the LCD if I touch the second sensor. I feel like I am pissing a tiny little bit of code in order to do so but I have no idea what.

ANY HELP WILL BE SO APPRECIATED I AM LITERALLY DESPERATE FOR ANY HELP :((

This is my code:

#include “LedControl.h”

#define sensorPin1 8 // capactitive touch sensor
#define sensorPin2 7

LedControl lc = LedControl(11, 13, 10, 256);

unsigned long delaytime = 300;
int rows[32] = {0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0};
int columns[8] = {0, 1, 1, 0, 0, 1, 1, 0};

void clearDisplay(int addr);

void setup() {
pinMode(sensorPin1, INPUT);
pinMode(sensorPin2, INPUT);
Serial.begin(9600);
//we have already set the number of devices when we created the LedControl
int devices = lc.getDeviceCount();
//we have to init all devices in a loop
for (int address = 0; address < devices; address++) {
lc.shutdown(address, false);
lc.setIntensity(address, 10);
lc.clearDisplay(address);
}
}

void loop() {

int senseValue1 = digitalRead(sensorPin1);
int senseValue2 = digitalRead(sensorPin2); // not using this atm

if (senseValue1 == HIGH) {

updateLEDs();

}

if (senseValue2 == HIGH) {

lc.clearDisplay(0); // so if I press the 2nd sensor it should clear the display??

}

void update() {

lc.clearDisplay(0); // I thought I can clear the display here??

}

void updateLEDs() {
for (int i = 8; i < 32; i–) {
for (int j = 0; j < 8; j++) {
//delay(100);
if (i < 8) {
//Serial.println(“First panel”);
lc.setLed(0, j, i, true);

}

if (i < 8 && i < 16) {
//Serial.println(“Second panel”);
lc.setLed(1, j, i, true);
//delay(200);
}

if (i < 24 && i < 32) {
//Serial.println(“Third panel”);
lc.setLed(2, j, i, true);
//delay(300);
}
if (i < 32) {
//Serial.println(“Forth panel”);
lc.setLed(3, j, i, true);
//delay(400);
}

/* disappearing LEDs
if (i < 32) {
Serial.println(“Forth panel”); //this is the fourth panel
lc.setLed(2, random(j), random(i), false);
delay(100);
}
if (i < 32) {
Serial.println(“Forth panel”); //this is the fourth panel
lc.setLed(1, random(j), random(i), false);
delay(100);
}
{
Serial.println(“Forth panel”); //this is the fourth panel
lc.setLed(0, random(j), random(i), false);
//delay(100);
}
{
Serial.println(“Forth panel”); //this is the fourth panel
lc.setLed(3, random(j), random(i), false);
//delay(100);
}
*/
}
}
}

void clearLEDs() {

int devices = lc.getDeviceCount();
//we have to init all devices in a loop
for (int address = 0; address < devices; address++) {
lc.shutdown(address, false);
lc.clearDisplay(address);
}
}

void clear() {
for (int i = 8; i < 32; i–) {
for (int j = 0; j < 8; j++) {
}
}
}

What do your Serial.print()s tell you is happening? Does the clearDisplay() method actually get called?
What kind of "capacative touch sensor" are you using? I've never heard anyone use digitalRead() to read one.

Hi Paul! Thanks a million for getting in touch! The Serial.print() prints 'first panel' when any LED on the first panel is turned on, prints 'second panel' when any LED on the second panel is turned on etc.. It's a bit useless I think, I just wanted to see whether I access them correctly. I use the ARCELI DIY 5PCS TTP223B (Digital Touch Capacitive Sensors) therefore I thought I had to use digitalRead to read them.

I use the ARCELI DIY 5PCS TTP223B (Digital Touch Capacitive Sensors)

That link doesn't work.