just a quick question, I'm looking to control the brightness of an LED strip depending on input signals through A0. I'm planning on having the Arduino read the input voltage and then multiply it by a certain integer then have it tell the motor shield how many dc volts to output to the LED strip. is this possible? can I ask the motor shield to say read voltage of A0, multiply it by 5, then output NewVoltage to motor one or something? is that within the motor shield's capability?
any advice or answers are much apprehended!
What kind of LED strip? Something with non-addressable LEDs? Those need a certain minimum voltage to turn on, and brightness is controlled by switching them on & off rapidbly -> PWM.
Which motor shield?
AaalogRead() results in 0 to 1023, analogWrite() needs 0 to 255.
CrossRoads:
What kind of LED strip? Something with non-addressable LEDs? Those need a certain minimum voltage to turn on, and brightness is controlled by switching them on & off rapidbly -> PWM.
Which motor shield?
AaalogRead() results in 0 to 1023, analogWrite() needs 0 to 255.
yeah it's just a cheap Ikea non individually addressable 12v LED strip, I'm using the regular Arduino motor shield of the official website rev3 or something. so I should just be able to ask the arduino to read the dc voltage from A0 then have it multiply that by something then have the motrosheild output that voltage? or how would it work with pwm?
https://store.arduino.cc/usa/arduino-motor-shield-rev3
that's the shield
thanks for the code although I'm not super confident I understand what it means. why does it need to be shifted? is that just moving the decimal to the right? and will those pwn pins be able to output 12 volts dc? cause my goal is to be able to plug the power leads of the led strip directly into the shield so it can use PWM to vary the brightness depending on the input voltage to A0
So, from the shield schematic, it looks like with 12V on VMOT and PWM on the PWM pins, the motor outputs wil be ~12V PWM.
You will have to control the DIRA, DIRB pins and the BRAKEA, BRAKEB pins also. Read the L298 datasheet to be sure.
Simpler code:
inputLevel = analogRead(A0); // read a pot, get 0 to 1023
outputLevel = inputLevel/4; change it to 0 255.
analogWrite (pwmPin, outputLevel); // send to shield pwm pin.