Hello
For my school project I will put a motor on my longboard and I want to control it with smartphone.
I found a code like this:
#include “FILENAME”
#includeSoftwareSerial Bluetooth(10, 11);
{
long previousMillis = 0;
long interval = 1000;
void setup()
{
Bluetooth.begin(9600);
Serial.begin(9600);
Serial.println(“Bluetooth On”);
ESC.attach(9);
}
void loop()
{
if (Bluetooth.available()){BluetoothData=Bluetooth.read();
ESC.write(BluetoothData);
Serial.println(BluetoothData);
}
int sensorValue = analogRead(A0);
float voltage = sensorValue * (5.0 / 1023.0);
unsigned long currentMillis = millis();
if (currentMillis – previousMillis > interval) {previousMillis = currentMillis;
if (voltage <= 3.5)Bluetooth.println(“Low Battery”);
else Bluetooth.println(voltage, DEC);
}
}
When I try to verify it it gives me this message:
Error compiling for board Arduino/Genuino Uno.
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.
Thank you in advance
exit status 1
Error compiling for board Arduino/Genuino Uno.
Is that the full error message ?
C:\Users\kasutaja\arduino\bluetooth_programme\bluetooth_programme.ino:1:20: fatal error: FILENAME: No such file or directory
#include "FILENAME"
^
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.
That is the full one.
So, do you have a file named FILENAME on your PC and if so, where is it located ?
No, i didn`t but when i saw the full error I saved my code as FILENAME but still the error message popped out.
It´s in C:\Users\kasutaja\Desktop\arduino
phantome:
No, i didn`t but when i saw the full error I saved my code as FILENAME but still the error message popped out.
No surprise there.
Where did you get the code from ?
#include "FILENAME"
Comment that line out.
UKHeliBob:
#include "FILENAME"
Comment that line out.
Now it gives me this.
FILENAME.ino:1: error: invalid preprocessing directive #includeSoftwareSerial
#includeSoftwareSerial Bluetooth(10, 11);
^
exit status 1
invalid preprocessing directive #includeSoftwareSerial
#includeSoftwareSerial Bluetooth(10, 11);
should be
#include SoftwareSerial Bluetooth(10, 11);
assuming that your Bluetooth device is connected to pins 10 and 11
phantome:
http://www.instructables.com/id/How-to-build-an-electric-Longboard-with-phone-cont/?ALLSTEPS
There is a download link for electric_longboard_v1.ino
. Use it instead of copy-pasting that butchered version you see on the page.
UKHeliBob:
#includeSoftwareSerial Bluetooth(10, 11);
should be
#include SoftwareSerial Bluetooth(10, 11);
assuming that your Bluetooth device is connected to pins 10 and 11
still error
and yes i will connect to pins 10 11
UKHeliBob:
#includeSoftwareSerial Bluetooth(10, 11);
should be
#include SoftwareSerial Bluetooth(10, 11);
assuming that your Bluetooth device is connected to pins 10 and 11
#include <SoftwareSerial.h>// import the serial library
#include <Servo.h>
SoftwareSerial Bluetooth(10, 11); // RX, TX
int BluetoothData; // the data given from Computer
Servo ESC;
long previousMillis = 0;
long interval = 1000;
void setup() {
// put your setup code here, to run once:
Bluetooth.begin(9600);
Serial.begin(9600);
Serial.println(“Bluetooth On”);
ESC.attach(9);
}
void loop() {
// put your main code here, to run repeatedly:
if (Bluetooth.available()){
BluetoothData=Bluetooth.read();
ESC.write(BluetoothData);
Serial.println(BluetoothData);
}
int sensorValue = analogRead(A0);
float voltage = sensorValue * (5.0 / 1023.0);
unsigned long currentMillis = millis();
if (currentMillis - previousMillis > interval) {
previousMillis = currentMillis;
if (voltage <= 3.5)
Bluetooth.println(“Low Battery”);
else
Bluetooth.println(voltage, DEC);
}
}
this one didnt give an error!! does it seem right
BluetoothData = Bluetooth.read();
ESC.write(BluetoothData);
Serial.println(BluetoothData);
What do you get from the read() ? Are they numbers or characters representing numbers ?
What is the ESC expecting to receive ?
UKHeliBob:
BluetoothData = Bluetooth.read();
ESC.write(BluetoothData);
Serial.println(BluetoothData);
What do you get from the read() ? Are they numbers or characters representing numbers ?
What is the ESC expecting to receive ?
umm what do you mean? I am quite new to all this, sorry
umm what do you mean? I am quite new to all this, sorry
As an example, there is a difference between receiving the character 4 followed by the character 5 and receiving the number 45. The ESC will almost certainly be expecting a number but it is very likely that what you are getting from Bluetooth is a string of characters.