First init.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* This example shows how to blink a pin on a seesaw.
|
||||
* It is written to use the built-in LED on the ATtiny817 breakout with seesaw.
|
||||
*/
|
||||
|
||||
#include "Adafruit_seesaw.h"
|
||||
|
||||
Adafruit_seesaw ss;
|
||||
|
||||
#define BLINK_PIN 5
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
while (!Serial) delay(10); // wait until serial port is opened
|
||||
|
||||
if(!ss.begin()){
|
||||
Serial.println("seesaw not found!");
|
||||
while(1) delay(10);
|
||||
}
|
||||
|
||||
Serial.println(F("seesaw started OK!"));
|
||||
|
||||
ss.pinMode(BLINK_PIN, OUTPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
ss.digitalWrite(BLINK_PIN, LOW); // turn the LED on (the LED is tied low)
|
||||
delay(1000); // wait for a second
|
||||
ss.digitalWrite(BLINK_PIN, HIGH); // turn the LED off
|
||||
delay(1000);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This example shows how to blink a pin on a seesaw.
|
||||
* Attach the positive (longer lead) of the LED to pin 15 on the seesaw, and
|
||||
* the negative lead of the LED to ground through a 1k ohm resistor.
|
||||
*/
|
||||
|
||||
#include "Adafruit_seesaw.h"
|
||||
|
||||
Adafruit_seesaw ss;
|
||||
|
||||
#define BLINK_PIN 15
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
while (!Serial) delay(10); // wait until serial port is opened
|
||||
|
||||
if(!ss.begin()){
|
||||
Serial.println("seesaw not found!");
|
||||
while(1) delay(10);
|
||||
}
|
||||
|
||||
Serial.println(F("seesaw started OK!"));
|
||||
|
||||
ss.pinMode(BLINK_PIN, OUTPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
ss.digitalWrite(BLINK_PIN, HIGH); // turn the LED on (HIGH is the voltage level)
|
||||
delay(100); // wait for a second
|
||||
ss.digitalWrite(BLINK_PIN, LOW); // turn the LED off by making the voltage LOW
|
||||
delay(100);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* This example shows how set GPIO interrupts on a seesaw.
|
||||
*/
|
||||
|
||||
#include "Adafruit_seesaw.h"
|
||||
|
||||
//connect the interrupt pin on the seesaw (pin 8 on samd09 breakout) to this pin on your arduino
|
||||
#define INT_PIN 3
|
||||
|
||||
//the interrupt will fire when this pin on the seesaw changes state
|
||||
#define SCAN_PIN 9
|
||||
|
||||
Adafruit_seesaw ss;
|
||||
|
||||
uint32_t mask = ((uint32_t)0b1 << SCAN_PIN);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
while (!Serial) delay(10); // wait until serial port is opened
|
||||
|
||||
if(!ss.begin()){
|
||||
Serial.println(F("seesaw not found!"));
|
||||
while(1) delay(10);
|
||||
}
|
||||
|
||||
Serial.println(F("seesaw started OK!"));
|
||||
|
||||
pinMode(INT_PIN, INPUT_PULLUP);
|
||||
ss.pinModeBulk(mask, INPUT_PULLUP);
|
||||
ss.setGPIOInterrupts(mask, 1);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if(!digitalRead(INT_PIN)){
|
||||
Serial.print(F("Interrupt fired! pin state: "));
|
||||
Serial.println(ss.digitalRead(SCAN_PIN));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* This example shows how to blink multiple pins at once on a seesaw.
|
||||
* pin 13 is attached to the LED on the samd11 xplained board
|
||||
*/
|
||||
|
||||
#include "Adafruit_seesaw.h"
|
||||
|
||||
Adafruit_seesaw ss;
|
||||
|
||||
//blink pins PA11, PA12, PA13
|
||||
uint32_t mask = ((uint32_t)0b111 << 11);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
if(!ss.begin()){
|
||||
Serial.println("ERROR!");
|
||||
while(1) delay(1);
|
||||
}
|
||||
else Serial.println("seesaw started");
|
||||
|
||||
ss.pinModeBulk(mask, OUTPUT); //set pin modes
|
||||
}
|
||||
|
||||
void loop() {
|
||||
ss.digitalWriteBulk(mask, HIGH); //set pins
|
||||
delay(1000); // wait for a second
|
||||
ss.digitalWriteBulk(mask, LOW); //clear pins
|
||||
delay(1000);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* This example shows how to read multiple pins at once on a seesaw.
|
||||
*/
|
||||
|
||||
#include "Adafruit_seesaw.h"
|
||||
|
||||
Adafruit_seesaw ss;
|
||||
|
||||
//read pins A8, A9, A10
|
||||
uint32_t mask = ((uint32_t)0b111 << 8);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
if(!ss.begin()){
|
||||
Serial.println("ERROR!");
|
||||
while(1) delay(1);
|
||||
}
|
||||
else Serial.println("seesaw started");
|
||||
|
||||
ss.pinModeBulk(mask, INPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.println(ss.digitalReadBulk(mask), BIN);
|
||||
delay(500);
|
||||
}
|
||||
Reference in New Issue
Block a user