Hi guys! ^___^
As I mentioned before, I was going to work on my coding skills, etc. so I thought I’d try my hand at making a basic wireless remote control for my robots (well, mainly for Red Nova ) using an ATmega328 (with the Arduino UNO bootloader).
So far, I have a basic design for the controller case and I’ll be using a circuit board I made to test out all the code before I make a simpler one for the controller.
Um …
Yep well this is the basic design for the controller - I originally intended to use two mini joysticks I found lying around but the touch screen uses up 4 of the 6 analogue pins with the other 2 being used for I2C on this board so I’ll have to stick to one and a variety of push buttons.
I still have to change the design to the new idea so I’ll upload an updated one soon.
When I say ‘graphical UI’, it’ll pretty much be just the screen changing images depending on which sector of the touch screen is pressed. :mrgreen:
Now onto the “test” board …
The board is composed of two sections; the ATmega328 (Master) IC and then the 12 Channel Servo Controller (Slave) IC. I thought it’d be better if I had all the I/O pins on the ATmega free for sensors, displays, etc. and then used the controller IC for the PWMs.
(1) - Sockets for sensors (or other small boards) with connected headers which allow pins on the board to be connected to various parts of the circuit via jumper cables.
(2) - 3.3V/5V lines - the jumper is currently set to 5V.
(3) - The 3.3V Regulator.
(4) - The I2C (SDA/SCL) lines.
I’ve just connected the touch screen up to the controller and it works pretty well (although I’ve read that they aren’t all that accurate but I’m not going to be doing anything super precise so it’s okay ^___^). The touch screen seems to have some ‘idle values’ so it’ll display random co-ordinates even though nothing is coming into contact with it; I need to find a way to get rid of that … Any suggestions?
You might have some questions about the power wiring for the board - long story short, I wanted to power the board using the output from one of my ESCs so I designed the board so that the GND for the ATmega IC connects to the negative for the battery (via the terminal block in the bottom right) so I have to connect both leads of my battery pack to power the board - the small one going to the ESC which then powers the board via the black and white cables (white being +5V) and the bigger one going into the terminal block - effort.
Oh, and sorry about the mess on the desk - I haven’t had a chance to clean it up.
I would have uploaded a video of the touch screen but it’s just a bunch of numbers on the Serial Monitor so it kinda seems pointless.
Um … oh yes, here are the parts I’m currently using (I still need to order the display):
2.2” LCD Display (with microSD breakout) - hobbytronics.co.uk/lcd/tft-lcd-2-2
Nintendo DS Touchscreen - hobbytronics.co.uk/lcd/nintendo-touch-screen
Touchscreen Breakout Board - hobbytronics.co.uk/lcd/nintendo-connector-breakout
You can find the code for it below:
[code]// Last Modified: April 5th 2013
// Description: Basic reading and displaying of values from a Touch Screen.
// Pin Mappings (Arduino - Breakout Board):
// A0 - Y1
// A1 - X2
// A2 - Y2
// A3 - X1
void setup()
{
}
int x_coordinate, y_coordinate = 0;
// Returns the value for the X-Axis.
int read_X()
{
int x_value = 0;
pinMode (A0, INPUT); // (Pin 23 on the ATmega328).
pinMode (A1, OUTPUT); // (Pin 24 on the ATmega328).
pinMode (A2, INPUT); // (Pin 25 on the ATmega328).
pinMode (A3, OUTPUT); // (Pin 26 on the ATmega328).
digitalWrite (A1, LOW);
digitalWrite (A3, HIGH);
delay (5);
x_value = analogRead (0);
return x_value;
}
// Returns the value for the Y-Axis.
int read_Y()
{
int y_value = 0;
pinMode (A0, OUTPUT); // (Pin 23 on the ATmega328).
pinMode (A1, INPUT); // (Pin 24 on the ATmega328).
pinMode (A2, OUTPUT); // (Pin 25 on the ATmega328).
pinMode (A3, INPUT); // (Pin 26 on the ATmega328).
digitalWrite (A0, LOW);
digitalWrite (A2, HIGH);
delay (5);
y_value = analogRead (1);
return y_value;
}
void loop()
{
Serial.begin(9600);
Serial.println ("x = ");
x_coordinate = read_X();
Serial.println (x_coordinate, DEC);
Serial.println ("y = ");
y_coordinate = read_Y();
Serial.println (y_coordinate, DEC);
delay (250);
}[/code]
That’s about it really … I’ll work on some kind of calibration for the touch screen and see if I can set it up to recognise some preset drawings (i.e. basic shapes, numbers, etc.). ^___^
AKdaBAOUS