Controlling a 12v 80 watt dc motor with an Arduino

Status
Not open for further replies.
In the IDE you should be using "Sketch->Upload" - not "Sketch->Upload using programmer".

Also, what does it say next to port on the Tools menu?

Mike.
Edit, can you get a list of connected devices and see if the port exists?
 
Here is what i got
 

Attachments

  • 62188012_2272322652813752_7263976203726356480_n.jpg
    800.7 KB · Views: 138
  • 62242472_324929721767213_7362720422439157760_n.jpg
    1.2 MB · Views: 137
  • 62211135_553146205215382_3777127169340211200_n.jpg
    955.9 KB · Views: 147
  • 62259102_462468777840179_7473584768278331392_n.jpg
    937.4 KB · Views: 120
  • 64401501_351144398924873_5209712063517032448_n.jpg
    977.8 KB · Views: 127
  • 62309468_309359816637190_7578560829918806016_n.jpg
    995.7 KB · Views: 120
If you unplug the board does the serial port disappear? It may be that the driver for the CH340 chip isn't installed.

Mike.
 
Sorry, I've always avoided apple due to them not playing nice with others, so I've no idea how to do anything. Maybe google "Getting stated with Arduino on a mac".

Mike.
 
The most common cause of errors like you see is the software is not seeing the hardware. Here is what I suggest. Using the cable provided connect your Arduino to your PC USB port. Assuming Windows open your Device Manager. In the device manager window look at Ports (COM & LPT) you should see your connected Arduino along with a COM ? where ? is the port number.

Now open your Arduino IDE and click Tools and select your Genuino Uno board.



Next setup your Com Port.


Try what we have so far and when you copy and past the code sample make sure you clear whet is there when you click file new to paste the whole code sample.

My bad on some of this, I see you were using a MAC so I can't be of any help with that.
Ron
 
If you have wired up the potentiometer then you can try reading it and printing it on the serial terminal.

Mike.
 
I’ll hook it up to in the morning and try that I haven’t assembled anything yet but I’ll hook it all up in the morning and see what it says on the terminal I’m getting the aluminum case for it Sunday
 
I just thought about something in the code sample I provided earlier for the motor speed. I have two delays in the code which make things easier to see when the code runs in the serial monitor. Those delays will likely also delay what happens when you adjust the motor speed making the response a little sluggish. Once everything is where you want it I would remove those two delays by preceding each line with //.

Something else you can change is the code is written:
{
// Read the PWM value of the input potentiometer.
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// map pump speed percent of full scale
percentValue = map (outputValue, 0, 255, 0, 100);
// change the analog out value:
analogWrite(pwmOutPin, outputValue);

What is happening in the above snippet is we are mapping the input and output. An analog input is mapped to a Digital PWM of 0 to 255 where 0 is no PWM and 255 is 100% PWM. You may wish to change the 0 to 255 to something like 50 to 255 or 100 to 255 just depends on your motor. I am sure you will get the idea. Also note from the code which Arduino pins I used.

Ron
 
With the code you last gave me i got this error

Arduino: 1.8.9 (Windows 10), Board: "Arduino/Genuino Uno"

sketch_jun13b:1:1: error: expected unqualified-id before '{' token

{

^

exit status 1
expected unqualified-id before '{' token

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
 
Ron's code needs to be placed in the main function,
Code:
#define analogInPin A0
#define pwmOutPin 2

uint16_t sensorValue,outputValue,percentValue;
    pinMode(pwmOutPin,OUTPUT);
    pinMode(analogInPin,INPUT);
void setup() {

}

void loop(){
  // Read the PWM value of the input potentiometer.
  sensorValue = analogRead(analogInPin);
  // map it to the range of the analog out:
  outputValue = map(sensorValue, 0, 1023, 0, 255);
  // map pump speed percent of full scale
  percentValue = map (outputValue, 0, 255, 0, 100);
  // change the analog out value:
  analogWrite(pwmOutPin, outputValue);
}

Note the above code expects a pot on A0 and the output will be on pin 2.

Mike.
Edit added setting the pin modes.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…