hello guys,
hope you all doing well
what i am doing here is a small RC car which i had, so I decided to build a speedometer by attaching a hall effect switch sensor and add some LEDs to the bottom, the top leds are controlled by a shift register
and controlling these by a controller which has 2 push buttons, an LCD 16x2, a TX RF module for 315mhz and a RX RF module for 433mhz
on the car side alongside the LEDs and hall effect switch sensor I have a RX RF module for 315mhz and a TX RF module for 433mhz
what i am doing is reading the data from the hall effect switch convert it to Speed then send this value by the RF to the controller and see this value on the LCD 16x2 and from the controller i can turn the LEDs on and off on the car
I attached every component now and i tested everything individually while everything is attached together
For the codes i write codes in which i am sending and receiving on every part (car and controller) so each one is sending and receiving, the codes compiled but did not work means nothing happened so i need your help to identify the problem.
I made some suggestion that might be the problem but still didn't get anything :
first i assumed these 2 lines should be put at the end of the void loop() function
vw_send((uint8_t*) & TransmittingArray, sizeof(TransmittingArray));
vw_wait_tx();
then i thought about this line of code might be making some problem by the wait
vw_wait_tx();
here are the codes for the Controller part :
//Sketch of the Controller of the RC car - Firas Helou
//Version September 6 2015
// include the libraries code for LCD and wireless RF Links :
#include <LiquidCrystal.h>
#include <VirtualWire.h>
const byte Red_LED = 2; //Top LEDs ON/OFF indicator
const byte Blue_LED = 4; //Bottom LEDs ON/OFF indicator
const byte TX_Pin = 3; //TX that sends data from the controller to the car
const byte RX_Pin = 5; //RX that receives data sent from the car
const byte RedLeds_Button = 6; //Push Button that turns the Top red LEDs on
const byte BlueLeds_Button = 7; //Push Button that turns the Bottom blue LEDs on
//String TopLed = "";
//String BottomLed = "";
LiquidCrystal lcd(8, 9, 10, 11, 12, 13); //defining the LCD pins
//controlling transmitter initially 12 - TX
int transmittingArray[5];
boolean lastRedLed = LOW;
boolean currentRedLed = HIGH;
boolean RedLedOn = false;
boolean lastBlueLed = LOW;
boolean currentBlueLed = HIGH;
boolean BlueLedOn = false;
byte valRedLedButton = 0;
byte valBlueLedButton = 0;
//controlling receiver - RX
int receivingArray[5];
//letter O
byte letter_O[8] = {
0b01110,
0b10001,
0b10001,
0b10001,
0b10001,
0b10001,
0b01110,
0b00000
};
//letter N
byte letter_N[8] = {
0b10001,
0b10001,
0b11001,
0b10101,
0b10011,
0b10001,
0b10001,
0b00000
};
//letter F
byte letter_F[8] = {
0b11111,
0b10000,
0b10000,
0b11110,
0b10000,
0b10000,
0b10000,
0b00000
};
//empty
byte empty[8] = {
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000
};
void setup() {
lcd.createChar(0,letter_O); // define our characters into the sketch as variables
lcd.createChar(1,letter_N);
lcd.createChar(2,letter_F);
lcd.createChar(3,empty);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.setCursor(3, 0);
lcd.print("KM/H:");
//Transmitter setup
vw_set_tx_pin(TX_Pin); //RF sending pin
vw_setup(2000); // Bits per sec
vw_set_rx_pin(RX_Pin);
vw_rx_start();
pinMode( RedLeds_Button, INPUT_PULLUP ); //RedLeds Button
pinMode( BlueLeds_Button, INPUT_PULLUP ); //BlueLeds Button
pinMode( Red_LED, OUTPUT ); //Red Led indicator Top LEDs
pinMode( Blue_LED, OUTPUT ); //Blue Led indicator Bottom LEDs
}
//Debouncing function
boolean debounce(boolean last, int button)
{
boolean current = digitalRead(button);
if(last != current)
{
delay(5);
current = digitalRead(button);
}
return current;
}
//Main Loop
void loop()
{
currentRedLed = debounce(lastRedLed, RedLeds_Button);
currentBlueLed = debounce(lastBlueLed, BlueLeds_Button);
if(lastRedLed == HIGH && currentRedLed == LOW){
RedLedOn = !RedLedOn;
valRedLedButton = 1;
}else if(lastRedLed == LOW && currentRedLed == HIGH){
valRedLedButton = 0;
}
lastRedLed = currentRedLed;
digitalWrite(Red_LED, RedLedOn);
lcd.setCursor(0, 1);
lcd.print("T-L:");
if(RedLedOn == HIGH){
//TopLed = "ON ";
lcd.setCursor(4, 1);
lcd.write(3);
lcd.setCursor(5, 1);
lcd.write((byte)0);
lcd.setCursor(6,1);
lcd.write(1);
}else if(RedLedOn == LOW){
//TopLed = "OFF";
lcd.setCursor(4, 1);
//lcd.print(TopLed);
lcd.write((byte)0);
lcd.setCursor(5,1);
lcd.write(2);
lcd.setCursor(6,1);
lcd.write(2);
}
if(lastBlueLed == HIGH && currentBlueLed == LOW){
BlueLedOn = !BlueLedOn;
valBlueLedButton = 1;
}else if(lastBlueLed == LOW && currentBlueLed == HIGH){
valBlueLedButton = 0;
}
lastBlueLed = currentBlueLed;
digitalWrite(Blue_LED, BlueLedOn);
lcd.setCursor(9, 1);
lcd.print("B-L:");
if(BlueLedOn == HIGH){
//BottomLed = "ON";
lcd.setCursor(13, 1);
lcd.write(3);
lcd.setCursor(14, 1);
lcd.write((byte)0);
lcd.setCursor(15,1);
lcd.write(1);
}else if(BlueLedOn == LOW){
lcd.setCursor(13, 1);
lcd.write((byte)0);
lcd.setCursor(14,1);
lcd.write(2);
lcd.setCursor(15,1);
lcd.write(2);
}
transmittingArray[0] = valRedLedButton;
transmittingArray[1] = valBlueLedButton;
vw_send((uint8_t*) & transmittingArray, sizeof(transmittingArray));
vw_wait_tx();
}// --- end of main Loop
Codes for the car are in the first comment