I already got help with my project on here, but I have come across another problem.
The motor is not working if I wire the Gate of the Mofset on the negative (-).
The led graph is working fine (left side).
The led on the right side is also working fine.
What I would like to have is a working motor and that it's functioning while I use the potentiometer.
It should be synschronized with the led graph on the left side and the led on the right side.
What am I doing wrong?
I've attached a picture of the circuit.
Thanks for your time and help!
Code:
#define MOF_PIN 12
const int analogPin = A0; // the pin that the potentiometer is attached to
const int ledCount = 8; // the number of LEDs in the bar graph
int ledPins[] = {
2, 3, 4, 5, 6, 7, 8, 9,
}; // an array of pin numbers to which LEDs are attached
void setup() {
// loop over the pin array and set them all to output:
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
pinMode(ledPins[thisLed], OUTPUT);
Serial.begin(9600);
}
}
void loop()
{
// read the potentiometer:
int pot = analogRead(analogPin);
// map the result to a range from 0 to the number of LEDs:
int ledLevel = map(pot, 0, 1023, 0, ledCount);
// loop over the LED array:
for (int thisLed = 0; thisLed < ledCount; thisLed++)
{
// if the array element's index is less than ledLevel,
// turn the pin for this element on:
if (thisLed < ledLevel)
{
digitalWrite(ledPins[thisLed], LOW);
}
// turn off all pins higher than the ledLevel:
else {
digitalWrite(ledPins[thisLed], HIGH);
}
}
// motor control
analogWrite(MOF_PIN, pot/4);
}
Your previous thread. Why did you delete your original post in that thread? Not cool. It takes away the context for all subsequent posts. To find your previous posts, click on your avatar, then below your avatar there will be a list of actions. Click on show posts.
I made a mistake there. I thought I didn't have to connect it to a pin. I will try it out Steve, thanks!
Thank you groundFungus! The reason I deleted my original post is because I thought it was working properly and that it was finished. It's my bad and I am very sorry for that. I've learned from my mistake. It seems like I can always come across more questions but I didn't realise it at that moment.
Now I know for next time. Thank you! I'm quite new to Arduino and a forum like this.
I'm still thinking about what DC motor I should use. I thought about a simple 3V motor but I am not quite sure about it yet.
I have heard that I could rather use a MOSFET than a normal transistor.
Using a MOFSET because my project is about PWM. I would like to control the speed of the motor as well as the blue led at the same time. The green leds are there to show how fast / how much power it is.
The current code I have is:
#define MOF_PIN 11
const int analogPin = A0; // the pin that the potentiometer is attached to
const int ledCount = 8; // the number of LEDs in the bar graph
int ledPins[] = { 2, 3, 4, 5, 6, 7, 8, 9,
}; // an array of pin numbers to which LEDs are attached
void setup() {
// loop over the pin array and set them all to output:
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
pinMode(ledPins[thisLed], OUTPUT);
Serial.begin(9600);
}
}
void loop()
{
// read the potentiometer:
int pot = analogRead(analogPin);
// map the result to a range from 0 to the number of LEDs:
int ledLevel = map(pot, 0, 1023, 0, ledCount);
// loop over the LED array:
for (int thisLed = 0; thisLed < ledCount; thisLed++)
{
// if the array element's index is less than ledLevel,
// turn the pin for this element on:
if (thisLed < ledLevel)
{
digitalWrite(ledPins[thisLed], HIGH);
}
// turn off all pins higher than the ledLevel:
else {
digitalWrite(ledPins[thisLed], LOW);
}
}
// motor control
analogWrite(MOF_PIN, pot/4);
}
Also attached a picture of the current circuit to this post.
I would like to hear what I could fix or do something in a better way.
I'm afraid you either missed or don't understand the "not a Fritzy" part. That are not circuit diagrams. A mess of wires, very hard to follow. No markings on the parts (values, pinout). Two light blue wires that go off screen - to where?
For circuit diagram, sketch one on paper, or install real circuit design software such as KiCAD or EagleCAD.
Anyway, do get rid of Fritzing. It's useless. Really.
BUT when you go to post the schematic, look for the "EXPORT as image" tool.
We all don't have the CAD that you use, but our browsers and OS will be happy displaying jpg file.
Thanks.. Tom...
PS A picture of a hand drawn circuit will be fine also.
I'm using KiCAD and love it except for its outright terrible library management, but luckily that's one of the least used bits (the moment you get the libraries added all is fine, and it comes with lots of libraries included). It's FOSS.
EagleCAD is another popular one, haven't tried it myself. The pages of Adafruit and Sparkfun always refer to EagleCAD.
Hi,
ExpressPCB is what I use, but I haven't used it to make a PCB commercially, I'm not sure if the latest version does, but it didn't make a Gerber file needed for PCB production.
Most of mine are one offs, so laser printer method is the usual way I make mine.
I prefer Express because it does not need buckets and buckets of hard-drive and is not encumbered with unnecessary parameters on the components and is easy to make and load components.
It boots real quick.
You don't have to go the full CAD route, although it would allow you to design a PCB for your components... you could use one of these free schematic editors: Schemit, CircuitBee and CircuitLab (used by electronics.stackexchange, my favorite). In fact, you can start to ask a question at stackexchange, then select the schematic editor [ctrl-M], but don't POST the question. Grab a screenshot of the "question".
When it looks good, export a JPG/PNG or
capture a screenshot of the schematic (ctrl-alt-print)
paste it into an image editing program (Paint, GIMP, IrfanView)
save it as a JPG/PNG
When you have a JPG file, attach it to your post (described here).
You could just use an image editing program to sketch it out (save as JPG/PNG). Or, like TomGeorge suggested, go old school and draw it on paper and take a pic. Attach the camera JPG as described above.