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