Could you tell me what's wrong with this code? It won't send a message to the user at all. | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Could you tell me what's wrong with this code? It won't send a message to the user at all.

#include <SoftwareSerial.h> #include <LiquidCrystal.h> SoftwareSerial mySerial(11, 10); LiquidCrystal lcd(7, 6, 5, 4, 3, 2); int gasPin = A0; int buzzerPin = 12; int data = 120; int greenLedPin = 8; int redLedPin = 9; void setup() { Serial.begin(9600); mySerial.begin(9600); mySerial.println("AT+CMGF=1"); delay(1000); mySerial.println("AT+CSCA=\"+639532248926\""); delay(1000); lcd.begin(16, 2); pinMode(gasPin, INPUT); pinMode(buzzerPin, OUTPUT); pinMode(greenLedPin, OUTPUT); pinMode(redLedPin, OUTPUT); lcd.begin(16, 2); lcd.clear(); lcd.setCursor(1, 0); lcd.print("GAS DETECTION"); lcd.setCursor(0, 1); lcd.print("SYSTEM"); delay(1000); lcd.clear(); } void loop() { int gasValue = analogRead(gasPin); Serial.print("Gas Value: "); Serial.println(gasValue); lcd.setCursor(0, 0); lcd.print("Gas Value: "); lcd.setCursor(12, 0); lcd.print(gasValue); delay(1000); if (gasValue > data) { lcd.clear(); lcd.setCursor(0, 0); lcd.print("GAS LEAKAGE");

13th May 2023, 10:34 AM
Xannus
Xannus - avatar
2 Respostas
+ 3
You didnā€™t close the last if block and the void loop() function. Add at the end of your code: } } And it might work
13th May 2023, 10:39 AM
Ugulberto SƔnchez
Ugulberto SƔnchez - avatar
+ 2
looks like an Arduino code. Hard to tell from the partial code. Could be hardware or software problem. Did you upload the program properly? Is your hardware working properly?
13th May 2023, 10:41 AM
Bob_Li
Bob_Li - avatar