Hello,
I’ve bought Uno (as the Duemilanove’s are discontinued) for my project.
I use port manipulation commands (DDRB and PINB) in my project and they are not working anymore on the Uno. As far as I now, there is nothing changed to the digital IO’s.
When I exchanged the Atmel 328 chips, I was able to read the inputs with the Duemilanove board and Uno Atmel chip! So, the Uno Atmel chip seems to be OK. But I was not able to read inputs with the Uno board and the Duemilanove Atmel chip.
Have anybody else experienced this or knows a solution?
This is the code that I’m using:
#include "pins_arduino.h"
int lastDigital = 0x0000;
void setup() {
DDRD &= B00000011; // 1-2 serial port (don't set) | 3-8 digital IN
DDRB &= B11000000; // 1-2 digital IN | 3-5 board ID | 6 sync | 7-8 nothing (don't set)
Serial.begin(19200);
}
void loop() {
byte temp1 = PIND & B11111100;
byte temp2 = PINB & B00111111;
int result = 0xf800 | (unsigned(temp1) >> 2) | (temp2 << 6);
if (result != lastDigital) {
if ((result & 0x00ff) != 0x0000) {
Serial.write(result >> 8);
Serial.write(result);
Serial.write((byte)0x00);
Serial.write((byte)0xff);
}
lastDigital = result;
}
}