First commit
This commit is contained in:
20
libraries/Lewis/examples/message_out/message_out.ino
Normal file
20
libraries/Lewis/examples/message_out/message_out.ino
Normal file
@ -0,0 +1,20 @@
|
||||
#include "Lewis.h"
|
||||
|
||||
Lewis Morse;
|
||||
|
||||
void setup() {
|
||||
// single recieve (RX) and transmit (TX) pin (simplex)
|
||||
// Lewis will switch the pin to OUTPUT as required to send
|
||||
Morse.begin(9);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Morse.print("ok");
|
||||
delay(1000);
|
||||
Morse.write('s');
|
||||
delay(1000);
|
||||
Morse.print(1);
|
||||
delay(1000);
|
||||
Morse.print(1.10);
|
||||
delay(1000);
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
#include "Lewis.h"
|
||||
#include <TimerOne.h>
|
||||
|
||||
Lewis Morse;
|
||||
|
||||
void setup() {
|
||||
// use the long form of Morse.begin to allow interrupts:
|
||||
// Morse.begin(rx_pin, tx_pin, words_per_minute, use_interrupts)
|
||||
Morse.begin(2, 9, 20, true);
|
||||
Timer1.initialize(10000);
|
||||
Timer1.attachInterrupt(myISR);
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Morse.print("ok");
|
||||
for (int i=0; i<4; i++) {
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
delay(250);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
delay(250);
|
||||
}
|
||||
}
|
||||
|
||||
void myISR()
|
||||
{
|
||||
Morse.timerISR();
|
||||
}
|
22
libraries/Lewis/examples/read_respond/read_respond.ino
Normal file
22
libraries/Lewis/examples/read_respond/read_respond.ino
Normal file
@ -0,0 +1,22 @@
|
||||
#include "Lewis.h"
|
||||
|
||||
Lewis Morse;
|
||||
|
||||
void setup() {
|
||||
// single recieve (RX) and transmit (TX) pin (simplex)
|
||||
// Lewis will switch the pin to OUTPUT as required to send
|
||||
Morse.begin(9);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// call checkIncoming often enough to catch the incoming presses
|
||||
Morse.checkIncoming();
|
||||
|
||||
if (Morse.available()) {
|
||||
char c = Morse.read();
|
||||
if (c == 'k') {
|
||||
delay(100);
|
||||
Morse.print("ok");
|
||||
}
|
||||
}
|
||||
}
|
38
libraries/Lewis/examples/serial_morse/serial_morse.ino
Normal file
38
libraries/Lewis/examples/serial_morse/serial_morse.ino
Normal file
@ -0,0 +1,38 @@
|
||||
#include "Lewis.h"
|
||||
#include <TimerOne.h>
|
||||
|
||||
Lewis Morse;
|
||||
|
||||
void setup() {
|
||||
// open the serial port
|
||||
Serial.begin(9600);
|
||||
// wait for serial port to connect on 32u4 boards (eg. Leonardo)
|
||||
while (!Serial){;}
|
||||
// use the long form of Morse.begin to allow interrupts:
|
||||
// Morse.begin(rx_pin, tx_pin, words_per_minute, use_interrupts)
|
||||
Morse.begin(2, 9, 20, true);
|
||||
// use the TimerOne library for a 100Hz timer interrupt
|
||||
Timer1.initialize(10000);
|
||||
Timer1.attachInterrupt(MorseISR);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// send each serial byte to Morse output
|
||||
if (Serial.available()) {
|
||||
int inByte = Serial.read();
|
||||
Morse.write(inByte);
|
||||
}
|
||||
|
||||
// send each Morse byte to serial port
|
||||
if (Morse.available()) {
|
||||
int inByte = Morse.read();
|
||||
Serial.write(inByte);
|
||||
}
|
||||
delay(500);
|
||||
}
|
||||
|
||||
// your own defined interrupt function that includes the Morse.timerISR call
|
||||
void MorseISR()
|
||||
{
|
||||
Morse.timerISR();
|
||||
}
|
38
libraries/Lewis/examples/serial_one_pin/serial_one_pin.ino
Normal file
38
libraries/Lewis/examples/serial_one_pin/serial_one_pin.ino
Normal file
@ -0,0 +1,38 @@
|
||||
#include "Lewis.h"
|
||||
#include <TimerOne.h>
|
||||
|
||||
Lewis Morse;
|
||||
|
||||
void setup() {
|
||||
// open the serial port
|
||||
Serial.begin(9600);
|
||||
// wait for serial port to connect on 32u4 boards (eg. Leonardo)
|
||||
while (!Serial){;}
|
||||
// use the long form of Morse.begin to allow interrupts:
|
||||
// Morse.begin(rx_pin, tx_pin, words_per_minute, use_interrupts)
|
||||
Morse.begin(9, 9, 20, true);
|
||||
// use the TimerOne library for a 100Hz timer interrupt
|
||||
Timer1.initialize(10000);
|
||||
Timer1.attachInterrupt(MorseISR);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// send each serial byte to Morse output
|
||||
if (Serial.available()) {
|
||||
int inByte = Serial.read();
|
||||
Morse.write(inByte);
|
||||
}
|
||||
|
||||
// send each Morse byte to serial port
|
||||
if (Morse.available()) {
|
||||
int inByte = Morse.read();
|
||||
Serial.write(inByte);
|
||||
}
|
||||
delay(500);
|
||||
}
|
||||
|
||||
// your own defined interrupt function that includes the Morse.timerISR call
|
||||
void MorseISR()
|
||||
{
|
||||
Morse.timerISR();
|
||||
}
|
Reference in New Issue
Block a user