Skywriter issue

I recently acquired an Skywriter sensor which was working fine with an Arduino just for a few minutes, but now it doesn´t work, without doing anything.

I´m using an Arduino Leonardo. The software version is the 1.8.1

I used he example at this link:

The wiring is the same as at the example:

|Skywriter|Arduino|
|VCC |5V|
|GND |GND|
|TRFR |GPIO 12|
|RESET |GPIO 13|
|SCL |SCL|
|SDA |SDA|

I changed a little bit the programing and all was working perfect. I just added a tap center and when I was testing it, it stopped working.

Then, I tried with the original programing but now with no success. The sensor is not sending anything anymore. I also tried comunicating via the serial port instead of the keyboard with no success and another sketchs to test the Arduino is fine, and it is(I tried with another new Leonardo…)

The code:

#include <skywriter.h>
#include <Keyboard.h>
#include <Wire.h>

#define PIN_TRFR 12 // TRFR Pin of Skywriter
#define PIN_RESET 13 // Reset Pin of Skywriter

long touch_timeout = 0;
int air_wheel_counter = 0;

void setup() {

Keyboard.begin();

Skywriter.begin(PIN_TRFR, PIN_RESET);

Skywriter.onTouch(touch);
Skywriter.onAirwheel(airwheel);
Skywriter.onGesture(gesture);

}

void loop() {

Skywriter.poll(); // Poll for any updates from Skywriter

if( touch_timeout > 0 ) touch_timeout–;
}

void enter(){
Keyboard.press(KEY_RETURN);
Keyboard.release(KEY_RETURN);
}

void gesture(unsigned char type){
switch (type){

case SW_FLICK_WEST_EAST:
  Keyboard.print("derecha");
  enter();
  break;

case SW_FLICK_EAST_WEST:
  Keyboard.print("izquierda");
  enter();
  break;

case SW_FLICK_SOUTH_NORTH:
  Keyboard.print("arriba");
  enter();
  break;

case SW_FLICK_NORTH_SOUTH:
  
  Keyboard.print("abajo");
  enter();
  break;

}
}

void airwheel(int number){
if( air_wheel_counter > 5 ){// Prevent the command being run excessive times for negligible difference
if( number > 0 ){ // If the wheel’s going in the “increase” direction
Keyboard.print(“reloj”);

}
else{
  
  Keyboard.print("antireloj"); 
     }

air_wheel_counter = 0;

}
else{
air_wheel_counter++;
}
touch_timeout = 10000;
}

void touch(unsigned char type){

Serial.print(type,DEC);
Serial.print(’\n’);

if( touch_timeout > 0 ) return; //Ensure that falsely detected touches within a small time interval of a real touch are ignored

switch (type) {

case SW_TOUCH_WEST: 
  break;

case SW_TOUCH_SOUTH:
  break;

case SW_TOUCH_NORTH:
  break;

case SW_TOUCH_EAST:
  break;

}

touch_timeout = 10000;
}

If you need further information don´t hesitate asking me.

Kind regards

You can format your code by placing it in 3 backticks:

```
# Like so
```

I’ll have to set this up on an Arduino and see if I can replicate - right now I’m not sure what’s up.

I was making more tests and I pretty sure the unit stopped working. I don´t know the cause, but it was working fine for some minutes and now it doesn´t, so I don´t think it could be related to the programming.
Regards

Curious- sure it’s not an intermittent wiring issue? I’ve not heard of one simply failing out of the blue like that.

Do you have a Raspberry Pi to test it on, using our Python library?

Yes, I have a Raspberry Pi to test it (although I never used it), so if you can send me the instructions I´ll test it, but as I told you I think the unit is wrong or something happened with it…
Thank you!

You should be able to install the Skywriter library on the Pi by running:

curl https://get.pimoroni.com/skywriter | bash

The MGC3130 chip on Skywriter is weird- sometimes it goes wonky for no explicable reason, it runs quite a significant chunk of software to process the gesture recognition and all of its output can be turned off. It’s possible this is fixable, but it’s very difficult to get any debugging information from one connected to an Arduino.