PI hat skywriter help

Status
Not open for further replies.
Update
Using an Arduino uno it works!
but not with a teensy 3.2
here is the sample code

Code:
#include <Wire.h>
#include <skywriter.h>

#define PIN_TRFR  2    // TRFR Pin of Skywriter
#define PIN_RESET 3    // Reset Pin of Skywriter

/////////////debugleds///////

int led10 = 10;
int led11=11;
int led12= 12;
int led13 =  13;

long touch_timeout = 0;
int air_wheel_counter = 0;

void setup() {
  Serial.begin(57600);
 
pinMode(led10,OUTPUT);
pinMode(led11,OUTPUT);
pinMode(led12,OUTPUT);
pinMode(led13,OUTPUT);

  
  Skywriter.begin(PIN_TRFR, PIN_RESET);

  // Bind skywriter events
  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(){

}

void gesture(unsigned char type){
  switch (type){
  
    case SW_FLICK_WEST_EAST:
 Serial.println(" SW_FLICK_WEST_EAST");
 digitalWrite(led10,HIGH);
 delay (100);
           digitalWrite(led10,LOW);
      break;
    
  
    case SW_FLICK_EAST_WEST:
       Serial.println(" EAST_WEST");
       digitalWrite(led11,HIGH);
       delay (100);
           digitalWrite(led11,LOW);
      break;

    
    case SW_FLICK_SOUTH_NORTH:
     Serial.println(" SOUTH_NORTH");
     digitalWrite(led12,HIGH);
     delay (100);
           digitalWrite(led12,LOW);
      break;
    
  
    case SW_FLICK_NORTH_SOUTH:
     Serial.println("NORTH_SOUTH");
     digitalWrite(led13,HIGH);
     delay (100);
           digitalWrite(led13,LOW);
      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
     
    }
    else{
     
    }
    
    air_wheel_counter = 0;
  }
  else{
    air_wheel_counter++;
  }
  touch_timeout = 10000;
}

void touch(unsigned char type){
  /*Serial.println("Got touch ");
  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: 
      Serial.println("SW_TOUCH_WEST");
      break;

    /* Launch selective area screenshot
     * Alt-; is the keyboard shortcut I have it bound to
     */
    case SW_TOUCH_SOUTH:
     Serial.println("SW_TOUCH_SOUTH");
      break;

    /* Launch spotify web player
     * Switch to chrome, open new tab, and start typing URL
     */
    case SW_TOUCH_NORTH:
    Serial.println("SW_TOUCH_NORTH");
      break;

    /* Launch facebook messenger
     * Switch to chrome, open new tab, and start typing URL
     */
    case SW_TOUCH_EAST:
     Serial.println("SW_TOUCH_EAST");
      break;

  }

  touch_timeout = 10000;
}
 
Your github link didn't work, here it is: https://github.com/pimoroni/skywriter-hat/tree/master/arduino/Skywriter

Looks like it uses Wire, are you using pins 18 and 19 of the 3.2? by default, those are the Wire pins. You should also call Wire.begin() in setup().. :)

EDIT: sorry the source code already calls Wire.begin();, check pins 18 & 19? You must also use pullups for I2C! without it, it wont work on teensy...
EDIT2: Just for the curious on logic level:

The Skywriter ( full sized ) has an onboard 3.3v low dropout regulator, so it’ll work with either a 5V or a 3.3V power supply. All of the data lines are level shifted, so they’ll also be fine.
 
Your github link didn't work, here it is: https://github.com/pimoroni/skywriter-hat/tree/master/arduino/Skywriter

Looks like it uses Wire, are you using pins 18 and 19 of the 3.2? by default, those are the Wire pins. You should also call Wire.begin() in setup().. :)

EDIT: sorry the source code already calls Wire.begin();, check pins 18 & 19? You must also use pullups for I2C! without it, it wont work on teensy...
EDIT2: Just for the curious on logic level:

Thanks!!
regarding Pullups is 1k a good value or less?
 
Status
Not open for further replies.
Back
Top