Hello,
my Name is Jannik and I'm new to this Forum and quite unexperienced about programming an Arduino.
That's why I'm looking for some help. I hope I'm writing in the right Topic section here ![]()
So I have the following problem:
I want to Control my Flipsky 6368/140kV by using an Arduino Nano, an Maytech VESC V4 and a Hallsensor like this:
https://www.ebay.de/i/283653872822?chn=ps&mkevt=1&mkcid=28
The purpose is to have all these Hardware running an E-Bike. I would like the Hallsensor connected to the Nano to register when someone is pushing the pedal. As long as this is happening the Motor should spin at a given speed.
If the sensor is not being triggered, the Motor should stop
My first try was to see if the Hallsensor is working properly using this code:
This example code is in the public domain.
*/
#define Eingang 2 // Drehzahl-Eingang: Pin2 / Interrupt 0
void setup() {
pinMode(Eingang, INPUT); // Eingangspin auf Eingang stellen
//digitalWrite(Eingang, HIGH); // und Pullup-Widerstand einschalten
Serial.begin(9600);
// Interrupt 0 auf Routine readmicros setzen
attachInterrupt(0, detectMagnet, FALLING);
Serial.println("Hall-Effekt-Sensor Test");
}
void loop() {
}
// Interrupt-Routine
// Diese Funktion wird immer dann aufgerufen, wenn ein Magnet vom Arduino erkannt wird
void detectMagnet() {
Serial.println("Magnet erkannt");
}
I attached the sensor to 5V, GND and Pin 2 and it works just fine. The monitor says "Magnet registered" when I hold a magnet close to it.
So this part is working!
On the other hand I was looking online for a code which includes an Hallsensor and the PPM Output to the VESC.
All I could find where different codes for a similar setup without the Hallsensor but instead with a potentiometer.
I am really trying to understand the coding but it's still new to me.
Therefore I would really appreciate some help from more experienced people to maybe just get the basic structure working!
I am looking forward to an answer and if I missed something about my seup let me know!
Thanks and have a good one.
Jannik