Show Posts
Pages: [1] 2
1  Using Arduino / Programming Questions / Re: Save state of Touch Screen on: May 04, 2013, 05:52:50 am
Ok, I finally found some time to do a bit more work on it and i have it done now.

I changed my code to use the TouchScreen library (found on github) after all. The reason it did not work in the first place was my own stupidity - I connected some wires wrong.

Then I added 3 LED for testing and divided the TouchScreen in three regions. Each LED can be changed in brightness by swiping from left to right on the screen at either the top, middle or bottom. This is neat for a RGB LED.

The library calculates the 'pressure' on the touch screen. That way it allows you to detect a touch and only write data to the LED when there is a touch in the correct region of the display. That way there is no need to save any data or to use interrupts. This makes the code incredibly simple.

//Notes for myself regading the wires
//connected to the 4-wire TouchScreen
// White and Purple = Y
// Gray and Blue = X

//Example from TouchScreen library
//With some custim LED stuff
#include <stdint.h>
#include "TouchScreen.h"

#define YP A3  // must be an analog pin, use "An" notation!
#define XM A2  // must be an analog pin, use "An" notation!
#define YM A1   // can be a digital pin
#define XP A0   // can be a digital pin

//PWM pins for the LEDs
int red = 9;
int green = 3;
int yell = 10;
int brightness = 0;
// For better pressure precision, we need to know the resistance
// between X+ and X- Use any multimeter to read it
// For the one we're using, its 300 ohms across the X plate
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 200);

void setup(void) {

void loop(void) {
  // a point object holds x y and z coordinates
  Point p = ts.getPoint();

  // we have some minimum pressure we consider 'valid'
  // pressure of 0 means no pressing!
  if (p.z > 25) {
    Serial.print("X = ");
    Serial.print("\tY = ");
    Serial.print("\tPressure = ");
    //Change colours by swipe in X direction
    //100 and 900 are values found from looking at the Serial output
    //of p.x
    //Divide the TouchScreen in 3 regions
    //bottom, middle, top, for three LEDs or RGB LED
    //values found by looking at p.y Serial output
    if(p.y < 350){
    else if (p.y > 350 & p.y < 660){


Project parts:
-4 wire resistive touch screen (ebay, search for nintendo DS replacement touch screen) 2.50GBP
-Breakout board for the flat cable (the screen has one of those flat cables and the pin pitch is 0.5mm. Impossible to solder if you do not have the right equipment for it. Further, for small quantities, the single connector is almost as expensive as the board. From proto-pic in the UK, I think adafruit in the US) 2.65GBP
- 3 LEDs or RGB LED with the appropriate resistors
2  Using Arduino / Programming Questions / Re: Save state of Touch Screen on: April 28, 2013, 05:56:33 pm
thanks fr the link.
I have the coordinate reading bit sorted already.

At the moment I am struggling with getting reliable pressure readings.

Once I can detect a touch it is indeed a lot easier because I can write data if the pressure is high enough.

The coordinate reading is very fast, but you are right, it is probably better not to read them at all as long as the pressure is too small.

I'll see how I get one
3  Using Arduino / Programming Questions / Re: Save state of Touch Screen on: April 28, 2013, 12:51:50 pm
I am not using any touch library as those did not work for me out of the box.
I have written my own bit of code. This is not so complicated. The screen has two layers one for x and one for y. You can the energize say X+ and make X- ground and then use either of the Y pins for sensing.
Then you energize the Y-plane and sense with a X pin.

If you want to know if a touch is happening you need to do the pressure detection. This is explained here,98328.0.html but I do not have it working yes. Sometimes I get negative values and the values of pressure are strongly correlated to the touch position.
4  Using Arduino / Programming Questions / Re: Save state of Touch Screen on: April 28, 2013, 12:02:40 pm
In the meantime I found that it apparently is possible to measure the touch pressure. I am looking into this now.
Then one might be able to trigger an interrupt once the pressure is above a threshold.

I know I could have a button that triggers an interrupt and then set the colour There is a Jeremy Blum tutorial on that, but it would be very neat
to have a touch only solution.
5  Using Arduino / Programming Questions / Save state of Touch Screen on: April 28, 2013, 07:52:59 am
Dear all,

I have a 4-wire resistive touch screen (yes, one of those Nintendo DS replacement ones) hooked up to my Arduino.

Now I want to control the brightness of a RGB LED with it. My idea was, that I use the y-axis as a brightness value and map it to a PWM pin.
Then I could divide the x-axis in three regions R,G and B.

I tink a piture explains it best

Now, when I release my finger or stylus from the touch screen, it obviously jumps back to a zero value which then would cause my LED to switch off.

How can I save the state/value from a touch and further, how can I save three different states?

6  Using Arduino / Project Guidance / Re: Bike shifter: direct servo, trigger shifter of grip shift? on: April 06, 2013, 12:33:10 pm
I have seen a project where someone did it, I just can't find the link again right now.
This guy, as far as I remember, used a servo to pull/release the cable and he trippered the shifting with two small buttons on the handle bars.

I would not bother with a grip shifter. In the end you need only two tiny buttons that you can push and then the servo will shift.
How would you sense in which position your grip shifter is anyway?

Usually grip shifts are only used in very low end bikes, don't use them and go for cool buttons  smiley-eek-blue
7  Using Arduino / Project Guidance / Re: What am I doing wrong?? on: March 19, 2013, 02:36:32 pm

note that you pmw output pins go from 0 -> 255, but you analog input pins from 0 ->1023. this means you have to use the map function to map the input to the output

it is also a good idea to use a constraint function around the map function just to make sure that the values always stay within the 0 -> 255 boundaries.

I based on the link above I have dimmed a RGB LED successfully.
8  Using Arduino / Project Guidance / Re: PWM Noisey in Mic. Amp Circuit on: March 11, 2013, 12:31:27 pm
I am building something similar at the moment (actually waiting for thr parts). I am planning to do this circuit below based on a tutorial by jeremy blum. This should, just like your description make an LED flash by amplifying the initial low voltage from the audio signal, followed by a buffer and a little storage to smooth the wave. 

The pot R1 is needed to fine tune the blinking by trimming the amplification value.

The amplification will cut off the negative part of the wave. The LM2 is kind off like a buffer and R3 and C1 will smooth over the gap that arises when you cut off half the wave.

It is explained in very much detail here (

9  Using Arduino / Project Guidance / Re: Using rele 12V on: February 15, 2013, 01:47:47 pm

have you connected the correct pin on your board?
In the blink example this is pin 13 as far as I know.

Is your Arduino running?

Is the red power LED on the relay board on?
10  International / Deutsch / Re: Li-ion Akku + ATtiny45 + Laser on: February 12, 2013, 12:00:43 pm

dioden brauchen eigentlich alle einen konstanten strom, aber das scheint nach den kommentaren zu diesem laser bereits auf der platine zu sein...
trotzdem braucht das ding wohl 250mA und kann damit nicht ueber einen Chip angesteuert werden. der kann ja nur max 40mA liefern?

Ich vermute das du den laser ueber einen mosfet oder so schalten musst (hast du ja in der zeinung drin) da sonst der stromfluss durch den tiny zu gross ist und er in rauch aufgeht.

jetzt waehre es interessant zu sehen wie die konstante stomquelle auf dem board realisiert wurde, denn dann koennte man feststellen, wie sich das geraet auf wechselnde spannungen reagiert... ein datenblatt hatte ich auf die schnelle nicht gesehen.

ich schliesse mich aber den anderen an. Ich habe einen gruenen 20mW laser in meinem labor und der muss entweder im schutzgehaeuse sein oder beim einrichten muss eine laserschutzbrille getragen werden. 10mW ist eine wahnsinns power konzentriert auf einen sehr kleinen punkt.

wenn du das ding kaufst, dann trage bei der montage keine uhr und keinen ring. befestige den laser fest auf einer oderflaeche und ziele auf z.b. eine schwarze pappe. der punkt wird trotzdem so hell sein, dass wenn du auf den lichtpunkt schaust dir deine augen wehtun. *sternchen*

fuer einen roten 3mW helium-neon laser brauche ich im labor schon ein sicherheitsdokument + lasereinweisung. das ist laserklasse IIIb.
den strahl siehst du aber nur wenn wie gesagt partikel das licht reflektieren.du kannst mal kochendes wasser oder trockeneis probieren oder auch ein deo das diese weissen partikel enthaelt (dann riecht es gleich noch super).

ein action-movie maessiges durch den strahl springen oder drunter durchtanzen kannst du dir aus dem kopf schlagen, sorry smiley
11  Topics / Science and Measurement / Re: Measuring system for dye-sensitized solar cells on: February 11, 2013, 08:53:20 am

first off, i do not have a out of the box solution for you, but maybe help in your search.

the way the circuit works is by measuring the voltage drop across a precise resistor which is in series with the load and then, using essentially ohms law,  convert the voltage drop to current. the resistor is often referred to as shunt resistor. this is how multimeters do current measurements as well.

the op amps like they are used in the circuit do pretty much the same thing, but they also give the voltage dropped across the resistor back to the circuit. that's why they are connected to the 5V line as well.

this video gives not a bad explanation on the subject

it should be possible to measure uAmps.
12  Using Arduino / Project Guidance / Re: Need power/voltage advice on: February 08, 2013, 03:16:25 pm
You can power your ardiono from a 9V battery. Actually the Arduino has a voltage regulator that allows you to use a range of input voltages.
Even 12V is possible, but not recommended. If the beacons should run of, lets say, 12V, then I would just take those 12V, but in a voltage regulator 12V->9V and run the Arduino of that.

The advantage is that you never need to change the battery.
There are also other voltage regulators that allow regulation to 9V from higher voltages (in case the beacons run at higher voltages).
Popular voltage regulators are the LM7809 series (just google for them).
The Arduino usually uses so little current that one beacon power supply should have no problem to power beacon and Arduino.

here is a picture of a potentail setup. really just a rough sketch.....
basically you cut ther + from the beacons and wire both to relays. those relays get switched by the arduino.
On one power supply you also hook up a voltage regulator that powers your arduino. the ground of all devices must be connected.

13  Using Arduino / Project Guidance / Re: 3w RGB color bar (BOM w/ TLC5940, Fets, UNL's on: February 01, 2013, 06:38:20 am

following Riva's tutorial for a constant current driver, I just finished the prototype for a 10W 350mA RGB LED. works great with PWM and the parts
were relatively cheap. For each channel: a simple NPN transistor, a Logic level mosfet, two resistors. Per channel maybe ~1.5£. The most expensice was the 12V wall PSU that I had to buy.
14  Using Arduino / Project Guidance / Re: Using an Arduino for home brewing. on: February 01, 2013, 06:30:36 am

what kind of board you need mainly depends on the number of in and outputs you require. This is the main difference between the boards.
If you want to control one pump, one heater/cooler and one thermometer, then you can use the Uno or even the nano.

If your pump is a simple on/off device, then you will need a relay to switch the pump. an Arduino can only take about 40mA of current on one of its output pins, but your pump will use a lot more. you will basically hook up your pump to the relay and to high voltage (wall socket) and use the Arduino to turn it on/off. just like a switch.
there are many solid state relays that can work directly with the Arduino, other relays may need another switch like a transistor or mosfet in between.

I assume that you will also have a heater/cooler that you want to control the vessel temperature with. you can do this based on a temperature input. you may want to consider some food grade thermistor or thermocouple if it will be submerged in the water/beer. thermistors will probably work directly on the Arduino analog input pins, but you need to calibrate it (thermistors vary their resistance with temperature and you basically read out resistor values). for a thermocouple, e.g. K-type, you need an extra chip to interface with it.

there is a PID control library that could work great for you in order to control the heater/chiller to reach your target temperature.

I think if you google for the individual parts that you want to control (pump/heater/temperature), you will find many tutorials. writing the program that connects all bits is then obviously something you need to do based on your requirements, but again there are many tutorials on e.g. relay switching...

15  Using Arduino / Project Guidance / Re: Project Feasability on: January 28, 2013, 02:44:19 pm
Sounds feasible to me. Most GUI stuff is written in the Processing language from what I have seen around (see also here:

But if you google arduino+gui you will find people who done this in matlab or Qt. I have found another interesting post here: It uses the AutoIt scripting language.

In the end it comes down to what software you are comfortable with and if the software can read/write serial data.

All the best
Pages: [1] 2