Hello to everyone.I have the Arduino Mega 2560 and i have a question.Which pins can be used for the digitalwrite function and what pins for the analogwrite function?Please help me.It's my first time with arduino mega(Always use the uno).Thanks in advance.
Just fire a google search and you can find a lot of post about that
You can use analogRead() on pins A0 thru A15.
You can use digitalRead() on every input pins, including A0 thru A15, except the pins whose hardware alternative function has been actived and the pins which are used by a software library called by your application -- for instance, don't use digital pins 0 (RX) and 1 (TX) if your application communicates with the PC thru the USB cable (with library Serial).
Hello sir and thank you for your reply.I have make a robot and on the pins 0 and 1 i have connect motors and without remove the pins the code upload fine.I don't had problem(because with the uno i had).Also when i remove the 0 and 1 pins all the motors rotate.Why this happens?
To understand better what i am sying, i post a part of my code.
// Motor Control Variables int PWM1 = 44; int ENABLE1 = 0; int PWM2 = 45; int ENABLE2 = 1; int PWM3 = 46; int ENABLE3 = 33; int PWM4 = 3; int ENABLE4 = 35;
pepe: When you upload a new sketch into your Arduino, no application is running, and the pins 0 and 1 are used by the USB interface.
Then, when your application is running, the pins 0 and 1 are used as outputs, but the USB interface is inactive.
This could become problematic if your application was trying to communicate thru the USB interface with the Serial object.
i have uncomment the serial and it works very well.
Also when i remove the 0 and 1 pins all the motors rotate.Why this happens?
You will have to provide what type of motors you are using and a schematic how they are exactly wired. This can be a scan / photo of a hand-drawn schematic.