Hi everyone,
I'm from France, and this year is my very last year at high school, and i have to lead an engineering project untill May, in order to pass my BAC (kind of French SAT). There's some electronics in my project so i decided to take an Arduino Nano (w/ Atmega 328) to control the whole device. The electronic circuit is quite basic : a DC Motor, controled by a H-bridge (L293D), a Arduino Nano, and some force sensors put into a Voltage/potential divider. The force sensors give me an analogic signal (between 0 and 5V) that i need to catch with the arduino, and then to ask for the motor's rotation. I managed to control my motor in both senses with a simple "digitalWrite(13,HIGH)" (without worrying about the force sensors). Now I need to have the motor turning in one sense, when my analog signal is > than 3,5 V. So i want it to be read, then converted from numeric values (from 0 to 1233) to the "real" analogic value (0 to 5V). So i use the step converter...
However i encountered a few problems :
The first one is that the output that should control the H-bridge, is directly High, whereas nothing is conected to the analog pin ...
The second one is that, in my program i say for example that : " const int Digital_Output_HBridge = 1 " (this means the variable Digital_Output is "connected" to pin D1 no?) ; But if i also write " const int Analog_Input_FSensor = 1 ", how can the Arduino understand that "Analog_Input_FSensor " is connected to A1 (and not D1 // I've tried to write const int Analog_Input_FSensor = A1, but it send me back an error message ...)
So i'm not sure, that " const int Analog_Input_FSensor = 1 " is correct
And i've tried to catch back the values on the Analog input, with the serial browse, but the values were fluctuating from like 200 to 400 but in a very random way, and i didn't catch any different values when my analog signal came from 0V to 5V (which i tested with a voltmeter) ; and i tried the different input pins, withoud any success ...
So please, if you can give me a clue it would be sooo great
And there is my program :
const int Analog_Input_FSensor = 1; // connected to A1
int value_read;
float U_value_read;
const int Digital_Output_HBridge = 4; // connected to D4
void setup ()
{
pinMode(Analog_Input_FSensor, INPUT);
pinMode(Digital_Output_HBridge, OUTPUT);
}
void loop ()
{
value_read = analogRead(Analog_Input_FSensor);
U_value_read = value_read*0.00489;
if (U_value_read>3,5);
digitalWrite(Digital_Output_HBridge , HIGH);
delay(500);
}
Thanks for your help !