So I'm trying to figure out how to make a switchblade PWM device. I'll have a wireless Relay/Mosfet set up to tell Arduino to switch between momentary commands. This is to control a brushless speed controller with fixed PWM input. I ask for help as i really do struggle writing code because of poor learning retention. Electronics I'm ok with due to it being hands on. So if any kind person can direct me in the right way that would be great.
Simple diagram of idea below
Remote swith with three functions
Off function 0% PWN output Always default function unless one of two switches pressed.
Switch 1 Momentary 30% PWM
Switch 2 Momentary 60% PWM
So Two inputs and Three PWM out puts for Arduino.
continuous script until turned off.
I'm looking to either make a circuit myself of just embed a current Arduino device already available smallest form factor possible 32bit preferable if you have any advice.
thank you all for any time and advice you can give.
Thank you Dr, The issue is i cannot comprehend how to write the code. i know i need to set pins for input and out put and PWM along with coding what pwm output for each switch etc. but I don't actually understand how that works. A switch in my hand is very east to understand but I don't understand how code works. sorry for being annoying but I'm being brutally honest as I'm struggling.
PWN level is governed by setting a number between 0 and 255 I believed I just don't understand how to implement it. and recommendation on a very small 32bit Arduino device?
If you want to do this project yourself then start with the IDE examples on button input and PWM. Else there is a Jobs and Paid Consultancy forum section for turnkey solutions.
Keep it simple and stupid firstly.
Run some tutorials for the hardware selected.
If you are happy with the results of the tutorials you can merge these to your project.
Thank you for replying. I've been working on this code for 6 months now, i have fairly severe learning issues related to reading and comprehension. That's why hands on is always better. i shall continue on and try and figure it out.
Currently don't have a board but i need it to be as small as possible and 32bit for future proofing reasons.
This is the code I've come up with and it wont work
#include <Servo.h>
Servo PWM; // create servo object to control a servo
int SwitchLow = 2; // Pin designation for Switch Medium Low
int SwitchMed = 3; // Pin designation for Switch Medium Speed
int val; // variable to read the value from the analog pin
void setup() {
PWM.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop1() {
val = digitalRead(SwitchLow); // reads SwitchLow
val = map(val, 0, 1, 0, 45); // Once Switch Low pressed Arduino will output 40% duty cycle of PWM
PWM.write(val); // sets the PWM according to the scaled value
delay(15); // waits 15ms
}
void loop2() {
val = digitalRead(SwitchMed); // reads SwitchMed
val = map(val, 0, 1, 0, 60); // Once Switch Med pressed Arduino will output 60% duty cycle of PWM
PWM.write(val); // sets the PWM according to the scaled value
delay(15); // waits 15ms
}
honestly I haven't a clue I am still struggling with understanding how the code works. Because its not actually in my hands and its virtual I can't just swap and replace component till i get it right.
just used the servo example and then tried to slice bit i kind of know to get it to work. one of the loops works on its own but when I add a second switch i falls apart. I'm using tinkercad Arduino simulator