-
1Code for Project
int sensorPin = 30;
int counter = 0;
#include <LiquidCrystal_I2C.h>#include <Wire.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup()
{
// setup serial - diagnostics - port
Serial.begin(9600);
pinMode(sensorPin, INPUT_PULLUP);
lcd.begin(16,2);
//initialize lcd screen
lcd.init();
// turn on the backlight
lcd.backlight();
}
void loop()
{
counter++;
int sensorValue = digitalRead(sensorPin);
Serial.print(counter);
Serial.print(" ");
Serial.println(sensorValue);
delay(250);
if(sensorValue == 0){
lcd.setCursor(0,1);
lcd.print("seat 1 needs help");
delay(5000);
lcd.setCursor(0,1);
lcd.print(" ");
}
} -
2Connecting Wires
3.3v or 5v on Mega Arduino Board to VCC on LCD Screen
GND on Mega Arduino Board to GND on LCD Screen
SCL on Mega Arduino Board to SCL on LCD Screen
SDA on Mega Arduino Board to SDA on LCD Screen
-
3Hall Effect Sensor Wiring
Hall Effect Sensor GND to Mega Arduino Board GND
Hall Effect Sensor +VCC to Mega Arduino Board 5V
Hall Effect Sensor Output to any digital pin on Mega Arduino Board (Use pin 30 if you don't want to have to change the code)
Put Resistor through output pin and 5V pin (10k Resistor)
Trevor Anderson
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.