From the following code you will see that I am trying to use PWM on pins 0 & 1 on an Arduino Mega 2560, which I think is possible as long as they are not used for Tx and Rx. I know that communication is required for uploading the code but after that point there is nothing in my code that is a serial function. How can I disable Tx and Rx so I can use PWM on pins 0 & 1?
void setup () {
for (int motorA = 22; motorA < 37; motorA++) {
pinMode (motorA, OUTPUT);
}
for (int motorB = 37; motorB < 54; motorB++) {
pinMode (motorB, OUTPUT);
}
for (int motorPWM = 0; motorPWM < 14; motorPWM++) {
pinMode (motorPWM, OUTPUT);
}
}
void loop () {
for (int motorA = 22; motorA < 37; motorA++) {
digitalWrite(motorA, HIGH);
}
for (int motorB = 37; motorB < 54; motorB++) {
digitalWrite(motorB, LOW); }
for (int motorPWM = 0; motorPWM <= 14; motorPWM++) {
analogWrite(motorPWM, 5);
}
On most Arduino boards (those with the ATmega168 or ATmega328), this function works on pins 3, 5, 6, 9, 10, and 11. On the Arduino Mega, it works on pins 2 through 13.