Hi,
I am fairly new to Arduino coding, I have looked at examples but can't find a fitting match for what I need to do. So I have looked at different code examples to try and make one which will work.
I have a SyRen 25 Motor Driver (https://www.dimensionengineering.com/datasheets/SyRen10-25.pdf) with an ELEGOO UNO R3 board and 2.4gHz radio control.
I want to add an ultrasonic sensor which when detects an object within x metres, it will then override the radio control input and brake the kart and not move until path is clear. However I wanted to start by controlling the SyRen with just Radio Control through the UNO to further my knowledge before I got any more adventurous.
I don't know how to send the signal which is converted from the Receiver signal to one which the SyRen can understand (0 - 180 degrees, 90 being stop, 180 being full forward and 0 being full reverse) to pin 8 which goes to the SyRen. Any advice or examples which are similar will be appreciated.
Many Thanks
/*
RC PulseIn Joystick
By: Nick Poole
SparkFun Electronics
Date: 5
License: CC-BY SA 3.0 - Creative commons share-alike 3.0
use this code however you'd like, just keep this license and
attribute. Let me know if you make hugely, awesome, great changes.
*/
// Here's where we'll keep our channel values
#include <Servo.h>
int ch2;
Servo SR;
int power = 0;
void setup() {
// Set our input pins as such
pinMode(6, INPUT);
SR.attach(9, 1000, 2000);
Serial.begin(9600); // Pour a bowl of Serial
}
void loop() {
int power;
// Read the pulse width of each channel
ch2 = pulseIn(6, HIGH, 25000);
SR.write(power);
for (power =
//Serial.print("Throttle"); // Ch2 was y-axis
//Serial.println(map(ch2, 1000,2000,0,180)); // center at 90 - Stopped
delay(10); //Time for servo1 to reach the value
//delay(100); //Time for Monitoring values
Serial.print("Throttle:"); //Serial debugging stuff
Serial.println(map(ch2, 1000, 2000, 0, 180)); // centre at 90 - Stopped
Serial.print("Power:"); //Serial debugging stuff
Serial.println(power);
}