Where is the Arduino Lilypad button?

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...

Any hints would be good, thanks in advance!

I would guess that external push buttons need to be connected with pulldown resistor to pin 4 and 19.

By the way, what do 'CHG' and 'ON' mean on the switch button?

just a guess (I don't own one), ON will turn the board ON, CHG will be to CHarGe the battery

Thanks for your reply!

I would guess that external push buttons need to be connected with pulldown resistor to pin 4 and 19.

So basically, Lilypad doesn't have a button, right? Do you mean I need to connect my Lilypad with a pulldown resistor to make a button?

just a guess (I don't own one), ON will turn the board ON, CHG will be to CHarGe the battery

Thank you, that sounds make sense to me :slight_smile:

I don't own one, but looking at the picture I don't see any buttons :slight_smile: (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 :slight_smile: , thank you. I think I'll just wait for someone else to see if they know about this problem.

Sounds like capacitive reaction on a floating pin - so probably not a feature of that board.
Get real buttons :wink:

I would probably use INPUT_PULLUP on those pins

All right, thank you!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.