0

Itsy Bitsy MO. HID keyboard. Help
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Itsy Bitsy MO. HID keyboard. Help

by Adaduder on Mon Mar 26, 2018 10:15 pm

Hello

Few questions if you could help that would be great. I'm trying to get Itsy Mo to work as a USB keyboard, using IDE (instead of python)
Can someone help?

All I would need is simple code example like if I press a button connect to pin 7 and have it type the letter "k"

that would be a big help, I could do it on leonardo boards, this has me stumped.


Side note:
I also agree with a few posters on here that there's not a lot of documentation on the board. not even a simple pin out. for example what pin is the RGB led on?

Adaduder
 
Posts: 13
Joined: Mon Mar 14, 2016 3:40 pm

Re: Itsy Bitsy MO. HID keyboard. Help

by danhalbert on Tue Mar 27, 2018 5:14 pm

Here's a program that writes out "x" whenever you press a button on pin 7. The other end of the button is connected to ground. I tested this and it works for me.

We're working on a Learn Guide for the Itsy Bitsy that will have detailed info - sorry it's taking longer than expected! The RGB LED is a DotStar and is on pins 40 and 41:
https://github.com/adafruit/ArduinoCore ... t.cpp#L186

Code: Select all | TOGGLE FULL SIZE
#include "Keyboard.h"

const int buttonPin = 7;

void setup() {
  pinMode(buttonPin, INPUT_PULLUP); 
  Keyboard.begin();
}

void loop() {
  if (!digitalRead(buttonPin)) {
    // debounce delay
    delay(100);
    Keyboard.print("x");
    // Wait for button to go back up.
    while (!digitalRead(buttonPin)) { }
  }
}

danhalbert
 
Posts: 2494
Joined: Tue Aug 08, 2017 12:37 pm

Re: Itsy Bitsy MO. HID keyboard. Help

by Adaduder on Tue Mar 27, 2018 9:14 pm

Amazing thanks a ton for helping, it's exactly what I was looking for.

-Note I tried to compile it, and it said to include the HID.h. but after I did that it compiled.

You rule.

Matt

Adaduder
 
Posts: 13
Joined: Mon Mar 14, 2016 3:40 pm

Re: Itsy Bitsy MO. HID keyboard. Help

by danhalbert on Tue Mar 27, 2018 9:59 pm

You're welcome! I did not have to include "HID.h", so that's a little odd. I'm using Arduino 1.8.5, with the board set to Itsy Bitsy M0, and with the latest board support packages for both Arduino (1.6.17) and Adafruit (1.0.22) SAMD M0. In the Library manager, I see version 1.0.1 of Keyboard.

danhalbert
 
Posts: 2494
Joined: Tue Aug 08, 2017 12:37 pm

Re: Itsy Bitsy MO. HID keyboard. Help

by Adaduder on Wed Mar 28, 2018 4:56 pm

That's strange I thought I updated all my boards and libraries. Maybe I have an old version of keyboard.

Thanks again this was a big help.

Adaduder
 
Posts: 13
Joined: Mon Mar 14, 2016 3:40 pm

Re: Itsy Bitsy MO. HID keyboard. Help

by Adaduder on Mon Apr 02, 2018 2:29 pm

For anyone trying to create a retropie controller or gameboy zero from the bitsy MO. I wrote this, could be a good way to start.

It has 17 inputs, works so far always open for suggestions on how to make it better. Next thing I want to do is make the dotstar react to different inputs. Different button different color. or something simple like that.

If anyone could post an example code of how to use the dotStar that would be awesome. I couldn't find anything on how to program a single dotstar, just info on strings. thanks again.

Code: Select all | TOGGLE FULL SIZE

#include "Keyboard.h"
#include "HID.h"

void setup() {
 
Keyboard.begin();


//Joystick and button connections
pinMode(7, INPUT_PULLUP); //Joystick Left Switch
pinMode(8, INPUT_PULLUP); //Joystick Right Switch
pinMode(9, INPUT_PULLUP); //Fire Button
pinMode(10, INPUT_PULLUP); //Joystick Left Switch
pinMode(11, INPUT_PULLUP); //Joystick Right Switch
pinMode(12, INPUT_PULLUP); //Fire Button
pinMode(13, INPUT_PULLUP); //Joystick Left Switch
pinMode(3, INPUT_PULLUP); //Joystick Right Switch
pinMode(4, INPUT_PULLUP); //Fire Button
pinMode(1, INPUT_PULLUP); //Joystick Left Switch
pinMode(2, INPUT_PULLUP); //Joystick Right Switch
pinMode(A1, INPUT_PULLUP); //Joystick Right Switch
pinMode(A2, INPUT_PULLUP); //Joystick Right Switch
pinMode(A3, INPUT_PULLUP); //Joystick Right Switch
pinMode(A4, INPUT_PULLUP); //Joystick Right Switch
pinMode(A5, INPUT_PULLUP); //Joystick Right Switch
pinMode(A0, INPUT_PULLUP); //Joystick Right Switch

}

void loop() {
 
// Check the switches:
int buttonState2 = digitalRead(7);
int buttonState3 = digitalRead(8);
int buttonState4 = digitalRead(9);
int buttonState5 = digitalRead(10);
int buttonState6 = digitalRead(11);
int buttonState7 = digitalRead(12);
int buttonState8 = digitalRead(13);
int buttonState9 = digitalRead(3);
int buttonState10 = digitalRead(4);
int buttonState11 = digitalRead(1);
int buttonState12 = digitalRead(2);
int buttonState13 = digitalRead(A1);
int buttonState14 = digitalRead(A2);
int buttonState15 = digitalRead(A3);
int buttonState16 = digitalRead(A4);
int buttonState17 = digitalRead(A5);
int buttonState18 = digitalRead(A0);

if (buttonState2 == LOW) {
Keyboard.press(218); //up
}
else {
Keyboard.release(218);
}


if (buttonState3 == LOW) {
Keyboard.press(217); //down
}
else{
Keyboard.release(217);
}

if (buttonState4 == LOW) {
Keyboard.press('l'); //down
}
else{
Keyboard.release('l');
}

if(buttonState5 == LOW) {
Keyboard.press(216); //left
}
else{
Keyboard.release(216);
}

if(buttonState6 == LOW) {
Keyboard.press(215); //right
}
else{
Keyboard.release(215);
}

if(buttonState7 == LOW) {
Keyboard.press('p');//A
}
else{
Keyboard.release('p');
}

if(buttonState8 == LOW) {
Keyboard.press(176); //B
}
else{
Keyboard.release(176);
}

if(buttonState9 == LOW) {
Keyboard.press('5'); //coin
}
else{
Keyboard.release('5');
}

if(buttonState10 == LOW) {
Keyboard.press('1'); //start
}
else{
Keyboard.release('1');
}

if(buttonState11 == LOW) {
Keyboard.press('x'); //x
}
else{
Keyboard.release('x');
}

if(buttonState12 == LOW) {
Keyboard.press('y'); //y
}
else{
Keyboard.release('y');
}

if(buttonState13 == LOW) {
Keyboard.press('c'); //ls
}
else{
Keyboard.release('c');
}

if(buttonState14 == LOW) {
Keyboard.press('v'); //rs
}
else{
Keyboard.release('v');
}

if(buttonState15 == LOW) {
Keyboard.press('d'); //Mode
}
else{
Keyboard.release('d');
}

if(buttonState16 == LOW) {
Keyboard.press('i'); //Mode
}
else{
Keyboard.release('i');
}

if(buttonState17 == LOW) {
Keyboard.press('k'); //Mode
}
else{
Keyboard.release('k');
}

if(buttonState18 == LOW) {
Keyboard.press('j'); //Mode
}
else{
Keyboard.release('j');
}


}


Adaduder
 
Posts: 13
Joined: Mon Mar 14, 2016 3:40 pm

Re: Itsy Bitsy MO. HID keyboard. Help

by danhalbert on Tue Apr 03, 2018 5:45 am

Adaduder wrote:If anyone could post an example code of how to use the dotStar that would be awesome. I couldn't find anything on how to program a single dotstar, just info on strings. thanks again.


Just use a DotStar string of length 1. That will work (Same for NeoPixels).

danhalbert
 
Posts: 2494
Joined: Tue Aug 08, 2017 12:37 pm

Please be positive and constructive with your questions and comments.