Hello, I'm very new to Arduino, so I have a very basic question now. Can anyone give me some help please?
I'm using Lilypad USB Arduino.
I'm doing a Lilypad tutorial now, my goal is to connect my lilypad to my unity project and here is the Arduino code.
#include "Keyboard.h"
// define the number of the pushbutton pins
const int button1Pin = 4; //lilypad left button
const int button2Pin = 19; //lilypad right button
void setup() {
//initialise the keyboard library
Keyboard.begin();
// initialize the pushbutton pin as an input:
pinMode(button1Pin, INPUT);
pinMode(button2Pin, INPUT);
}
void loop() {
//read the button1 state and check if it is pressed
if (digitalRead(button1Pin) == HIGH) {
//send the A character as a keyboard press.
Keyboard.write('A');
}
//read the button2 state and check if it is pressed
if (digitalRead(button2Pin) == HIGH) {
//send the D character as a keyboard press.
Keyboard.write('D');
}
//wait for 0.1 seconds between keypresses.
delay(10);
}
After I upload this code, I don't know where's the button. But if I switch the button on the lily pad, it will show a lot of 'A' and a little 'D'.
By the way, what do 'CHG' and 'ON' mean on the switch button? I've tried to find the meaning of them on Arduino DOC, but I can't find it...
I don't own one, but looking at the picture I don't see any buttons (besides reset and the switch to charge or turn it on) (unless the pads are touch sensitive ?)
If I change the button1Pin and button2Pin number to some other numbers, and then I touch that little circles around Lilypad, it seems have some responses. However, I don't see any law from it, it is kind of random to me. Because even I just put my Lilypad on a flat table, it will also type 'A', but if I touch some specific circle, it will type more 'A' or 'D'.
No probs friend , thank you. I think I'll just wait for someone else to see if they know about this problem.