In the image above we have an illustration of the construction we are trying to build with a diagram of the connections between the LDR,LED and the keyboard. The construction consists of large squares that are on the floor and by stepping on them you activate a keyboard key (up/down arrows and so on…)
The buttons have openings from where light comes through to the LDRs that are beneath.
When you step on the button so that there is no light comin through to the LDR, the LED turns on and stays on until the LDR detects light turnong off the LED.
When the LED is on we want arduino to send signal to press the keyboard key that is designated to the button, for instance the up arrow.
We believe that this code can suit our needs for the first part of the project. But obviously it is wrong so if anyone knows how to fix it please inform us.
int ledPin = 13; // LED connected to digital pin 13
int LDR = 0; //LDR input
int val = 0; //setup inital stored value
void setup() // run once, when the sketch starts
pinMode(ledPin, OUTPUT); // sets the digital pin as output
void loop() // run over and over again
val = analogRead(LDR); // if LDR val = 0
digitalWrite(ledPin, HIGH); // sets the LED on
val = analogRead(LDR); // if LDR val>0
digitalWrite(ledPin, LOW); // sets the LED off
Also, we don’t know how to do the second part where the LED sends signal to the keyboard to activate the up arrow.
we don’t know how to…
We? Who is we? What is this project for?
I may be willing to help depending on those questions…
ITS THE GOVERNMENT, MAN1!!!
MAN1: ITS THE GOVERNMENT!!!
MAN2: NO IT’S NOT!!!
I mean if it’s a school/college assignment then I could give some pointers…
It’s for a university project… We are a group of students attempting to construct this for the purposes of a virtual environment presentation, where a person can control his movements with his body position.
We’ve searched everywhere but there doesn’t seem to exist a code for the keyboard arrows. Do we have to install a library or another application?
We’ve searched everywhere
I doubt it the internet is quite a big place.
or another application?
When you detect something with the arduino you can output a character on the serial port. What you need is an application that looks at that port and does what you want it to do. However if you have not got access to the code of your application on the PC you need a mapping application that will look at the serial port and send a character into the operating system as if it were a key press.
As you only give a sketchy idea of what you want to do I can only give you a sketchy answer.
If you can’t find a serial to keyboard mapper, consider going through MIDI. There are lots of applications that map received MIDI data into keystrokes on all platforms. So then you need to make your arduino output MIDI. Look in the playground for examples of this.