I'm having problems reading the analogue pin and sending the value through Bluetooth to my LCD.
can someone tell me whats wrong please, thank you very much.
This is the code for the master device
and then i get this error message
This is the code for the slave device
can someone tell me whats wrong please, thank you very much.
This is the code for the master device
Code:
int val;
#define button 3
void setup() {
Serial.begin(38400);
pinMode(button , INPUT);
}
void loop() {
val = digitalRead(button);
if (val == HIGH)
{
int sensor = analogRead(A0);
float voltage0 = sensor * (5.0/1023.0);
Serial.write(voltage0);
delay(500);
}
delay(50);
}
Code:
Arduino: 1.8.4 (Windows 7), Board: "Arduino/Genuino Uno"
C:\Sams Folder\Code_for_master_device__full_\Code_for_master_device__full_.ino: In function 'void loop()':
Code_for_master_device__full_:16: error: call of overloaded 'write(float&)' is ambiguous
Serial.write(voltage0);
^
C:\Sams Folder\Code_for_master_device__full_\Code_for_master_device__full_.ino:16:26: note: candidates are:
In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:232:0,
from sketch\Code_for_master_device__full_.ino.cpp:1:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:129:20: note: virtual size_t HardwareSerial::write(uint8_t)
virtual size_t write(uint8_t);
^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:130:19: note: size_t HardwareSerial::write(long unsigned int)
inline size_t write(unsigned long n) { return write((uint8_t)n); }
^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:131:19: note: size_t HardwareSerial::write(long int)
inline size_t write(long n) { return write((uint8_t)n); }
^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:132:19: note: size_t HardwareSerial::write(unsigned int)
inline size_t write(unsigned int n) { return write((uint8_t)n); }
^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:133:19: note: size_t HardwareSerial::write(int)
inline size_t write(int n) { return write((uint8_t)n); }
^
exit status 1
call of overloaded 'write(float&)' is ambiguous
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int val;
int voltage0;
int Intvol;
void setup() {
Serial.begin(38400);
lcd.begin(16, 2);
}
void loop() {
if(Serial.available() > 0)
{
val = Serial.read();
if (val==voltage0)
{
lcd.setCursor (0,0);
lcd.print(val);
delay(200);
}
}
}