How to write a program that controls a motor [closed] - microcontroller

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
Connecting a motor to move a laser pointer up/down left/right to draw patterns.
Has anyone seen any examples to help the project? What programming language would be used for this? What computer ports would this use? Does a custom circuit have to be made or does a store exist for this?

There is a lot of different approaches you could go to this. Here is a few off the top of my head.
1. You could use a micro controller like an Arduino.
2. You could use a serial port and a socket. Here would be a good resource if you want to pursue this route. http://www.easysw.com/~mike/serial/serial.html
3. If you only need to control two motors you could use the headphone jack on your computer. You could hook a simple amplifier circuit up to each of the left and right speaker line. Then hook each of the amplifiers up to a separate motor. Then you could write a program that generates a separate sound for each channel, thus modifying the voltage given to each motor.
P.S if you use a servo, you can control the exact angle of the laser.

Related

How would I find out what day it is on an arduino without any external stuff? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Trying to find out what day it is on an Arduino without an external clock or internet.
I'm at boarding school and I'm making a program that tells me how many sleeps/days are left until Saturday (when I go home). I've understood how an LCD works but I'm struggling with finding out what day it is. I'm quite new to Arduino so go easy on the terminology :)
You can count days from arduino start using millis() but if you need to countdown to specific day you have to synchronize correct date using RTC.
Code for count days from arduino start:
float days = millis()/1000/60/60/24;
I'm afraid an Arduino, on its own, will lose track of time every time it loses power. And even when it stays powered on, the internal clock is not too accurate.
The usual fix for this is to use an attached RTC (Real Time Clock) circuit powered by a button cell, such as the Adafruit DS3231 Precision RTC Breakout
RTCs usually have accuracy similar to typical clocks or watches.
A key part of this is the battery to keep time even when the device has power interruptions. (Also, Adafruit includes links to code for connecting to an Arduino.)
If you are willing to set the time on the Arduino pretty often (maybe off by a minute every day?), you can use a solution like this:
https://create.arduino.cc/projecthub/plouc68000/simplest-uno-digital-clock-ever-4613aa
millis() and delay() will not be very accurate on most Arduinos and will be off by a few percent. Even worse, that accuracy will change depending on local conditions, such as temperature. (You could always luck out and get a great combination of board and environmental conditions for yours to be more accurate, but don't count on it.)

First step Arduino Uno R3? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I won the arduino uno r3 in an event, but I have doubts about how to take the first steps to learn how to program it. I would like to understand which courses I am looking for that work for my arduino model (uno r3) and which programming languages and which IDEs I can use. So I can look for a course in Udemy or another platform that I can learn without having to buy an arduino of another brand
The only language you really need to know to code an Arduino is C++. Even with just the basics, you can do quite a lot. These are some things I think are a must to know:
Variables
If Statments
Loops
Importing Classes
Calling Functions
Next you can download the Arduino IDE, and start coding. Look up tutorials on YouTube to get a hand of the different commands you have at your finger tips and how to compile and upload your code to the board. You'll be using different functions such as digitalWrite() which can be used to turn an LED connected to a certain pin on or off, and many more.
In short, learn C++, and look up YouTube tutorials and you should be good.
Although you won't need to take classes for the programming side, you may need to take some when creating circuits with the Arduino. Electronics can be hard to learn, and some people may need some resource other than YouTube to learn that.

Obtaining encoder data [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Hello and in advance thank you for reading my post,
I am working on a project which is controlled by a stepper motor which also includes an encoder. I have made the motor running and now I want to proceed to the next step and include the functions of the encoder. I know that the encoder tells me the actual position travelled by the motor, however, as I am still quite a newbie, I have unfortunately no idea how to include the information of my encoder into my code (which library? which variables). Both motor and encoder are connected to my Arduino Uno and I have also attached a photo with the corresponding pins for the encoder.
Thank you for any much required help
Here's a huge list of resources and libraries, that should get you started: http://playground.arduino.cc/Main/RotaryEncoders
I'd recommend using this library as it automatically takes advantage of the interrupt capabilities, if you connect the encoder to the correct pins (2 & 3 on the Uno). You might need this in order to still get precise measurements even at high rpm.

arduino mega draw more current from pins [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have the Arduino Mega,
i need more than the 40mA supplied by the pins to power up my dc-motors,
Is there a way to increase those 40mA to more like 100mA or so?
thanks
This isn't an SO question since it doesn't have anything to do with programming ... but anyway: You don't want to be driving a motor directly from an Arduino. Aside from the lack of adequate power, the motor will also generate spikes and electronic noise which will affect the Ardunio.
There are loads of tutorials on the web here's one. If you want to be able to reverse direction then you would use what is called an H-Bridge.
You can instead of connecting the dc motor with 1 pin to each terminal (+ve, -ve)
you can connect 2 or more (to add-up the current)
assuming a pin gives 40mA and you need 100mA, then you can connect each terminal from the dc-motor to 3 pins from the arduino providing 120mA

Line Tracking Robot [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 13 years ago.
Improve this question
Me and my friends are building a line tracking robot based on my previous question about how to track white line on a black surface. We settled on using photo resistors and a arduino board. Now all the reflectance sensors I've found are should be placed very close to the line 1 - 2 cm above the line. Now one of my team mates had a heated argument with the professor that there are reflectance sensors that can track 10cm or more but we could not find any.
Are there any type of sensor that would allow us to track the line farther away?
Using an arduino, you are most likely going to use the pololu library for reflectance sensors. Even using an array of sensors of this type, you are looking at a maximum sensing distance of just UNDER a cm (9.5 mm.) I think your teammate was out by a factor of ten, you can score this one to the professor!
The lego light sensor is a good example of this type of sensor. If you can get your hands on an NXT kit, it is an alternative to the arduino. And who doesn't enjoy playing with lego!!
Kindness,
Dan
You need a laser sensor if you want a range more than a few centimeters and don't want to bother with doing it yourself. Google for "laser contrast sensor" if you really need it.
One way to increase sensitivity is, lighting the white band with an array of LEDs perpendicular to it and sequentially turning one on and off, tracking the reading of the photoresistor in software. Of course you probably want to optically focus the LEDs some and use modulation to minimize interference if you use simple photoelements. It will be interesting to see the actual distribution of resistance values along the LED array on the white line.

Resources