Hello,
I'm trying to setup a 2-way serial communication between 2 devices:
TouchShield Slide (from Liquidware) from/to atmel 1284p using
SoftwareSerial library.
I've setup a test example to see how it works ( arduino UNO and
TouchShield Slide) and it'is work fine but when I try with 1284p don't
work
I upload the sketch to 1284p with a avr programmer ( without a
bootloader) and I use mighty-1284p core with this pin mapping
// ATMEL ATMEGA1284P
//
//
+---/---+
//
(D 0) PB0 1| |40 PA0 (AI 0 / D24)
//
(D 1) PB1 2| |39 PA1 (AI 1 / D25)
//
INT2 (D 2) PB2 3| |38 PA2 (AI 2 / D26)
//
PWM (D 3) PB3 4| |37 PA3 (AI 3 / D27)
//
PWM/SS (D 4) PB4 5| |36 PA4 (AI 4 / D28)
//
MOSI (D 5) PB5 6| |35 PA5 (AI 5 / D29)
//
PWM/MISO (D 6) PB6 7| |34 PA6 (AI 6 / D30)
//
PWM/SCK (D 7) PB7 8| |33 PA7 (AI 7 / D31)
//
RST 9| |32 AREF
//
VCC 10| |31 GND
//
GND 11| |30 AVCC
//
XTAL2 12| |29 PC7 (D 23)
//
XTAL1 13| |28 PC6 (D 22)
//
RX0 (D 8) PD0 14| |27 PC5 (D 21) TDI
//
TX0 (D 9) PD1 15| |26 PC4 (D 20) TDO
//
RX1/INT0 (D 10) PD2 16| |25 PC3 (D 19) TMS
//
TX1/INT1 (D 11) PD3 17| |24 PC2 (D 18) TCK
//
PWM (D 12) PD4 18| |23 PC1 (D 17) SDA
//
PWM (D 13) PD5 19| |22 PC0 (D 16) SCL
//
PWM (D 14) PD6 20| |21 PD7 (D 15) PWM
//
+--------+
//
tounchshiled pin mapping http://www.liquidware.com/wikipages/name/Pins
Sketch for 1284p
#include <SoftwareSerial.h>
// RX1/INT0 (D 10) PD2 16
// TX1/INT1 (D 11)
#define RX_PIN 10
#define TX_PIN 11
SoftwareSerial touchSerial = SoftwareSerial(RX_PIN, TX_PIN);
// Globals
long randNumber;
void setup() {
touchSerial.begin(9600);
}
void loop() {
randNumber = random(300);
if(touchSerial.available())
{
char c = (char)touchSerial.read();
if (c == 'A')
{
touchSerial.print(randNumber);
delay(100);
}
}
}
sketch for TouchShield
// Globals
unsigned int Xstore;
unsigned int Ystore;
// Prepare Screen and Serial
void setup()
{
background(0,0,0);
stroke(255,255,255);
fill(0,0,0);
Serial.begin(9600);
delay(100);
}
void loop()
{
// Monitor TouchShield Slide for touches
gettouch();
// Check if there are new touches
// If yes, send serial command to Arduino
if ( mouseX != Xstore || mouseY != Ystore )
{
Serial.print("A");
delay(50);
}
Xstore = mouseX;
Ystore = mouseY;
// Monitor Serial Buffer of TouchShield Slide
char charIn = 0;
byte i = 0;
char stringIn[32] = "";
while(Serial.available()) {
charIn = Serial.read();
stringIn = charIn;
- i += 1;*
}
// Clear screen and display the serial buffer as text
if (stringIn[0])
{ - background(0,0,0);*
- text(stringIn, mouseX+75, mouseY+75, 30, 30);*
}
}
what is wrong? How i can debug it?
thanks