├── HC06_HC05_BC04_AT09_bluetooth_config
└── HC06_HC05_BC04_AT09_bluetooth_config.ino
├── README.md
├── bluethooth_manual
├── BC04-B_AT Command.pdf
├── BLE-CC41-A_AT Command.pdf
├── DX-BT05-A 4.0 AT Commands (Chinese).pdf
├── HC-03 HC-05 Embedded Bluetooth Serial Communication Module_AT_commamd_set_201104_revised.pdf
├── JNHuaMao Technology Company Bluetooth 4.0 BLE module Datasheet.pdf
└── hc06 data sheet AT command.pdf
├── four_in_one_demo_mod_fix_v0.1.ino
├── four_in_one_demo_mod_fix_v0.2.ino
├── four_in_one_demo_mod_fix_v0.3.ino
├── four_in_one_demo_mod_fix_v0.4.ino
├── four_in_one_demo_mod_fix_v0.5.ino
└── libraries
├── Arduino-IRremote
├── .gitignore
├── .travis.yml
├── Contributors.md
├── IRremote.cpp
├── IRremote.h
├── IRremoteInt.h
├── LICENSE.txt
├── README.md
├── changelog.md
├── examples
│ ├── AiwaRCT501SendDemo
│ │ └── AiwaRCT501SendDemo.ino
│ ├── IRrecord
│ │ └── IRrecord.ino
│ ├── IRrecvDemo
│ │ └── IRrecvDemo.ino
│ ├── IRrecvDump
│ │ └── IRrecvDump.ino
│ ├── IRrecvDumpV2
│ │ └── IRrecvDumpV2.ino
│ ├── IRrelay
│ │ └── IRrelay.ino
│ ├── IRremoteInfo
│ │ └── IRremoteInfo.ino
│ ├── IRsendDemo
│ │ └── IRsendDemo.ino
│ ├── IRsendRawDemo
│ │ └── IRsendRawDemo.ino
│ ├── IRtest
│ │ └── IRtest.ino
│ ├── IRtest2
│ │ └── IRtest2.ino
│ ├── JVCPanasonicSendDemo
│ │ └── JVCPanasonicSendDemo.ino
│ └── LGACSendDemo
│ │ ├── LGACSendDemo.ino
│ │ └── LGACSendDemo.md
├── irPronto.cpp
├── irRecv.cpp
├── irSend.cpp
├── ir_Aiwa.cpp
├── ir_Denon.cpp
├── ir_Dish.cpp
├── ir_JVC.cpp
├── ir_LG.cpp
├── ir_Mitsubishi.cpp
├── ir_NEC.cpp
├── ir_Panasonic.cpp
├── ir_RC5_RC6.cpp
├── ir_Samsung.cpp
├── ir_Sanyo.cpp
├── ir_Sharp.cpp
├── ir_Sony.cpp
├── ir_Template.cpp
├── ir_Whynter.cpp
├── keywords.txt
├── library.json
└── library.properties
├── BatReader
├── BatReader.cpp
├── BatReader.h
├── BatReader.zip
└── BatReader_Example
│ └── BatReader_Example.ino
├── EnableInterrupt
├── EnableInterrupt.h
├── EnableInterrupt.zip
├── README.md
├── examples
│ ├── AllPins2560
│ │ ├── AllPins2560.ino
│ │ └── Makefile
│ ├── AllPins328
│ │ ├── AllPins328.ino
│ │ └── Makefile
│ ├── EnableInterruptTest
│ │ └── EnableInterruptTest.ino
│ ├── HiSpeed
│ │ ├── HiSpeed.ino
│ │ ├── Makefile
│ │ └── README
│ ├── HiSpeedAllPins2560
│ │ ├── HiSpeedAllPins2560.ino
│ │ └── Makefile
│ ├── HiSpeedAllPins328
│ │ ├── HiSpeedAllPins328.ino
│ │ └── Makefile
│ ├── HiSpeedTest
│ │ ├── HiSpeedTest.ino
│ │ └── Makefile
│ ├── InterruptedPin2560
│ │ ├── InterruptedPin2560.ino
│ │ └── Makefile
│ ├── InterruptedPin328
│ │ ├── InterruptedPin328.ino
│ │ └── Makefile
│ ├── Mighty1284p
│ │ └── Mighty1284p.ino
│ ├── OOSimple
│ │ ├── Makefile
│ │ └── OOSimple.ino
│ ├── Simple
│ │ ├── Makefile
│ │ └── Simple.ino
│ ├── SimpleFunctionWithArg
│ │ ├── Makefile
│ │ └── SimpleFunctionWithArg.ino
│ └── Testing
│ │ ├── Makefile
│ │ └── Testing.ino
├── extras
│ ├── LICENSE
│ ├── NOTICE
│ └── RELEASE_NOTES
└── utility
│ ├── ei_External1284.h
│ ├── ei_External2560.h
│ ├── ei_External328.h
│ ├── ei_ExternalLeonardo.h
│ ├── ei_PinChange1284.h
│ ├── ei_PinChange2560.h
│ ├── ei_PinChange328.h
│ ├── ei_PinChangeLeonardo.h
│ ├── ei_pindefs_speed.h
│ ├── ei_porta_speed.h
│ ├── ei_portb_speed.h
│ ├── ei_portc_speed.h
│ ├── ei_portd_speed.h
│ ├── ei_portj_speed.h
│ └── ei_portk_speed.h
├── I2Cdev
├── I2Cdev.cpp
├── I2Cdev.h
├── keywords.txt
└── library.json
├── LedMatrix
├── LedMatrix.cpp
├── LedMatrix.h
├── LedMatrix.zip
└── LedMatrix_Code
│ └── LedMatrix_Code.ino
├── MAX7219-MAX7221.pdf
├── MPU6050
├── MPU6050.cpp
├── MPU6050.h
├── MPU6050_6Axis_MotionApps20.h
├── MPU6050_9Axis_MotionApps41.h
├── examples
│ ├── IMU_Zero
│ │ └── IMU_Zero.ino
│ ├── MPU6050_DMP6
│ │ ├── MPU6050_DMP6.ino
│ │ └── Processing
│ │ │ └── MPUTeapot
│ │ │ └── MPUTeapot.pde
│ ├── MPU6050_DMP6_Ethernet
│ │ └── MPU6050_DMP6_Ethernet.ino
│ └── MPU6050_raw
│ │ └── MPU6050_raw.ino
├── helper_3dmath.h
└── library.json
├── MaxMatrix
├── MaxMatrix.cpp
├── MaxMatrix.h
└── MaxMatrix.ino
├── MsTimer2
├── MsTimer2.cpp
├── MsTimer2.h
└── examples
│ └── FlashLed
│ └── FlashLed.pde
├── NewPing
├── NewPing.cpp
├── NewPing.h
├── examples
│ ├── NewPing15Sensors
│ │ └── NewPing15Sensors.pde
│ ├── NewPingEventTimer
│ │ └── NewPingEventTimer.pde
│ ├── NewPingExample
│ │ └── NewPingExample.pde
│ └── TimerExample
│ │ └── TimerExample.pde
└── keywords.txt
├── Oscillator
├── Oscillator.cpp
└── Oscillator.h
├── Otto
├── Otto.cpp
├── Otto.h
├── Otto_gestures.h
├── Otto_mouths.h
└── Otto_sounds.h
├── OttoSerialCommand
├── OttoSerialCommand.cpp
└── OttoSerialCommand.h
├── PS2X_lib
├── Examples
│ ├── PS2X_Example
│ │ └── PS2X_Example.ino
│ └── PS2X_Example_ArduinoMega
│ │ └── PS2X_Example_ArduinoMega.ino
├── PS2X_lib.cpp
├── PS2X_lib.h
└── keywords.txt
├── US
├── US.cpp
└── US.h
└── readme.txt
/README.md:
--------------------------------------------------------------------------------
1 | # arduino-smart-robot-car
2 | How to make smart robot car with Arduino Uno and Arduino Mega (IR RC + Bluetooth RC + Obstacle Avoidance + Line Tracking)
3 |
4 |
5 |
6 | ## S/W Instruction
7 | 1. Access http://www.arduino.org/
8 | 2. Download Arduino IDE 1.7.8 or later version
9 | 3. Install it
10 | 4. Access https://smartmecard.wordpress.com
11 | 5. Download smart robot car source code file (four_in_one_demo_mod_fix_xxx.ino) in https://github.com/smartmecard/arduino-smart-robot-car
12 | 6. Download library files from https://github.com/smartmecard/arduino-smart-robot-car/tree/master/libraries
13 | 8. Go to C:\Users\your_pc_id\Documents\Arduino\libraries
14 | 9. Copy library files to C:\Users\your_pc_id\Documents\Arduino\libraries
15 | 10. Go to C:\Program Files\Arduino\libraries and rename RobotIRremote folder name as RobotIRremote_backupAccess folder name
16 | 11. Run Arduino IDE 1.7.8 or later version
17 | 12. Load four_in_one_demo_mod_fix_xxx.ino
18 | 13. Sketch > Compile or Ctr+ R
19 | 14. Compiling will be successful
20 | 15. Connect usb cable to arduino and upload program
21 |
22 | ## Guide and Demo
23 | [How to make smart robot car with Arduino Uno and Arduino Mega (IR RC + Bluetooth RC + Obstacle Avoidance + Line Tracking) Guide and Demo] (https://youtu.be/G-Q8FEqmgZU)
24 |
--------------------------------------------------------------------------------
/bluethooth_manual/BC04-B_AT Command.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smartmecard/arduino-smart-robot-car/c5a0554a11c4e41a61c79af503f3163ffec319cb/bluethooth_manual/BC04-B_AT Command.pdf
--------------------------------------------------------------------------------
/bluethooth_manual/BLE-CC41-A_AT Command.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smartmecard/arduino-smart-robot-car/c5a0554a11c4e41a61c79af503f3163ffec319cb/bluethooth_manual/BLE-CC41-A_AT Command.pdf
--------------------------------------------------------------------------------
/bluethooth_manual/DX-BT05-A 4.0 AT Commands (Chinese).pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smartmecard/arduino-smart-robot-car/c5a0554a11c4e41a61c79af503f3163ffec319cb/bluethooth_manual/DX-BT05-A 4.0 AT Commands (Chinese).pdf
--------------------------------------------------------------------------------
/bluethooth_manual/HC-03 HC-05 Embedded Bluetooth Serial Communication Module_AT_commamd_set_201104_revised.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smartmecard/arduino-smart-robot-car/c5a0554a11c4e41a61c79af503f3163ffec319cb/bluethooth_manual/HC-03 HC-05 Embedded Bluetooth Serial Communication Module_AT_commamd_set_201104_revised.pdf
--------------------------------------------------------------------------------
/bluethooth_manual/JNHuaMao Technology Company Bluetooth 4.0 BLE module Datasheet.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smartmecard/arduino-smart-robot-car/c5a0554a11c4e41a61c79af503f3163ffec319cb/bluethooth_manual/JNHuaMao Technology Company Bluetooth 4.0 BLE module Datasheet.pdf
--------------------------------------------------------------------------------
/bluethooth_manual/hc06 data sheet AT command.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smartmecard/arduino-smart-robot-car/c5a0554a11c4e41a61c79af503f3163ffec319cb/bluethooth_manual/hc06 data sheet AT command.pdf
--------------------------------------------------------------------------------
/four_in_one_demo_mod_fix_v0.5.ino:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smartmecard/arduino-smart-robot-car/c5a0554a11c4e41a61c79af503f3163ffec319cb/four_in_one_demo_mod_fix_v0.5.ino
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/.gitignore:
--------------------------------------------------------------------------------
1 | *.un~
2 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/.travis.yml:
--------------------------------------------------------------------------------
1 | language: python
2 | python:
3 | - "2.7"
4 |
5 | env:
6 | - PLATFORMIO_CI_SRC=examples/AiwaRCT501SendDemo PLATFORMIO_BUILD_FLAGS="-DSEND_AIWA_RC_T501"
7 | - PLATFORMIO_CI_SRC=examples/IRrecord PLATFORMIO_BUILD_FLAGS="-DSEND_NEC -DSEND_SONY -DSEND_RC5 -DSEND_RC6"
8 | - PLATFORMIO_CI_SRC=examples/IRrecvDemo
9 | - PLATFORMIO_CI_SRC=examples/IRrecvDump
10 | - PLATFORMIO_CI_SRC=examples/IRrecvDumpV2
11 | - PLATFORMIO_CI_SRC=examples/IRrelay
12 | - PLATFORMIO_CI_SRC=examples/IRsendDemo PLATFORMIO_BUILD_FLAGS="-DSEND_SONY"
13 | - PLATFORMIO_CI_SRC=examples/IRtest PLATFORMIO_BUILD_FLAGS="-DSEND_NEC -DSEND_SONY -DSEND_RC5 -DSEND_RC6"
14 | - PLATFORMIO_CI_SRC=examples/IRtest2 PLATFORMIO_BUILD_FLAGS="-DSEND_NEC -DSEND_SONY -DSEND_RC5 -DSEND_RC6"
15 | - PLATFORMIO_CI_SRC=examples/JVCPanasonicSendDemo PLATFORMIO_BUILD_FLAGS="-DSEND_JVC -DSEND_PANASONIC"
16 | - PLATFORMIO_CI_SRC=examples/IRremoteInfo
17 |
18 | install:
19 | - python -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)"
20 |
21 | script:
22 | - platformio ci --lib="." --board=uno --board=leonardo --board=pro16MHzatmega168
23 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/Contributors.md:
--------------------------------------------------------------------------------
1 | ## Contributors
2 | These are the active contributors of this project that you may contact if there is anything you need help with or if you have suggestions.
3 |
4 | - [z3t0](https://github.com/z3t0) : Active Contributor and currently also the main contributor.
5 | * Email: zetoslab@gmail.com
6 | * Skype: polarised16
7 | - [shirriff](https://github.com/shirriff) : An amazing person who worked to create this awesome library and provide unending support
8 | - [Informatic](https://github.com/Informatic) : Active contributor
9 | - [fmeschia](https://github.com/fmeschia) : Active contributor
10 | - [PaulStoffregen](https://github.com/paulstroffregen) : Active contributor
11 | - [crash7](https://github.com/crash7) : Active contributor
12 | - [Neco777](https://github.com/neco777) : Active contributor
13 | - [Lauszus](https://github.com/lauszus) : Active contributor
14 | - [csBlueChip](https://github.com/csbluechip) : Active contributor, who contributed major and vital changes to the code base.
15 |
16 | Note: This list is being updated constantly so please let [z3t0](https://github.com/z3t0) know if you have been missed.
17 |
18 |
19 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/README.md:
--------------------------------------------------------------------------------
1 | # IRremote Arduino Library
2 |
3 | [](https://travis-ci.org/z3t0/Arduino-IRremote)
4 |
5 | [](https://gitter.im/z3t0/Arduino-IRremote?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
6 |
7 | This library enables you to send and receive using infra-red signals on an Arduino.
8 |
9 | Check [here](http://z3t0.github.io/Arduino-IRremote/) for tutorials and more information.
10 |
11 | ## Version - 2.01
12 |
13 | ## Installation
14 | 1. Navigate to the [Releases](https://github.com/z3t0/Arduino-IRremote/releases) page.
15 | 2. Download the latest release.
16 | 3. Extract the zip file
17 | 4. Move the "IRremote" folder that has been extracted to your libraries directory.
18 | 5. Make sure to delete Arduino_Root/libraries/RobotIRremote. Where Arduino_Root refers to the install directory of Arduino. The library RobotIRremote has similar definitions to IRremote and causes errors.
19 |
20 | ## Usage
21 | - TODO (Check examples for now)
22 |
23 | ## Contributing
24 | If you want to contribute to this project:
25 | - Report bugs and errors
26 | - Ask for enhancements
27 | - Create issues and pull requests
28 | - Tell other people about this library
29 | - Contribute new protocols
30 | -
31 |
32 | ## Contact
33 | The only way to contact me at the moment is by email: zetoslab@gmail.com
34 | I am not currently monitoring any PRs or Issues due to other issues but will respond to all emails. If anyone wants contributor access, feel free to email me. Or if you find any Issues/PRs to be of importance that my attention is needed please email me.
35 |
36 | ## Contributors
37 | Check [here](Contributors.md)
38 |
39 | ## Copyright
40 | Copyright 2009-2012 Ken Shirriff
41 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/changelog.md:
--------------------------------------------------------------------------------
1 |
2 | ## 2.0.2 - 2015/12/02
3 | - Added IRremoteInfo Sketch - [PR](https://github.com/z3t0/Arduino-IRremote/pull/241)
4 | - Enforcing changelog.md
5 |
6 | ## 2.0.1 - 2015/07/26 - [Release](https://github.com/shirriff/Arduino-IRremote/releases/tag/BETA)
7 | ### Changes
8 | - Updated README
9 | - Updated Contributors
10 | - Fixed #110 Mess
11 | - Created Gitter Room
12 | - Added Gitter Badge
13 | - Standardised Code Base
14 | - Clean Debug Output
15 | - Optimized Send Loops
16 | - Modularized Design
17 | - Optimized and Updated Examples
18 | - Improved Documentation
19 | - Fixed and Improved many coding errors
20 | - Fixed Aiwa RC-T501 Decoding
21 | - Fixed Interrupt on ATmega8
22 | - Switched to Stable Release of @PlatformIO
23 |
24 | ### Additions
25 | - Added Aiwa RC-T501 Protocol
26 | - Added Denon Protocol
27 | - Added Pronto Support
28 | - Added Library Properties
29 | - Added Template For New Protocols
30 | - Added this changelog
31 | - Added Teensy LC Support
32 | - Added ATtiny84 Support
33 | - Added ATtiny85 Support
34 | - Added isIdle method
35 |
36 | ### Deletions
37 | - Removed (Fixed) #110
38 | - Broke Teensy 3 / 3.1 Support
39 |
40 | ### Not Working
41 | - Teensy 3 / 3.1 Support is in Development
42 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/examples/AiwaRCT501SendDemo/AiwaRCT501SendDemo.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
3 | * An IR LED must be connected to Arduino PWM pin 3.
4 | * Version 0.1 July, 2009
5 | * Copyright 2009 Ken Shirriff
6 | * http://arcfn.com
7 | */
8 |
9 | #include "IRremote.h"
10 |
11 | #define POWER 0x7F80
12 | #define AIWA_RC_T501
13 |
14 | IRsend irsend;
15 |
16 | void setup() {
17 | Serial.begin(9600);
18 | Serial.println("Arduino Ready");
19 | }
20 |
21 | void loop() {
22 | if (Serial.read() != -1) {
23 | irsend.sendAiwaRCT501(POWER);
24 | delay(60); // Optional
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/examples/IRrecord/IRrecord.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * IRrecord: record and play back IR signals as a minimal
3 | * An IR detector/demodulator must be connected to the input RECV_PIN.
4 | * An IR LED must be connected to the output PWM pin 3.
5 | * A button must be connected to the input BUTTON_PIN; this is the
6 | * send button.
7 | * A visible LED can be connected to STATUS_PIN to provide status.
8 | *
9 | * The logic is:
10 | * If the button is pressed, send the IR code.
11 | * If an IR code is received, record it.
12 | *
13 | * Version 0.11 September, 2009
14 | * Copyright 2009 Ken Shirriff
15 | * http://arcfn.com
16 | */
17 |
18 | #include
19 |
20 | int RECV_PIN = 11;
21 | int BUTTON_PIN = 12;
22 | int STATUS_PIN = 13;
23 |
24 | IRrecv irrecv(RECV_PIN);
25 | IRsend irsend;
26 |
27 | decode_results results;
28 |
29 | void setup()
30 | {
31 | Serial.begin(9600);
32 | irrecv.enableIRIn(); // Start the receiver
33 | pinMode(BUTTON_PIN, INPUT);
34 | pinMode(STATUS_PIN, OUTPUT);
35 | }
36 |
37 | // Storage for the recorded code
38 | int codeType = -1; // The type of code
39 | unsigned long codeValue; // The code value if not raw
40 | unsigned int rawCodes[RAWBUF]; // The durations if raw
41 | int codeLen; // The length of the code
42 | int toggle = 0; // The RC5/6 toggle state
43 |
44 | // Stores the code for later playback
45 | // Most of this code is just logging
46 | void storeCode(decode_results *results) {
47 | codeType = results->decode_type;
48 | int count = results->rawlen;
49 | if (codeType == UNKNOWN) {
50 | Serial.println("Received unknown code, saving as raw");
51 | codeLen = results->rawlen - 1;
52 | // To store raw codes:
53 | // Drop first value (gap)
54 | // Convert from ticks to microseconds
55 | // Tweak marks shorter, and spaces longer to cancel out IR receiver distortion
56 | for (int i = 1; i <= codeLen; i++) {
57 | if (i % 2) {
58 | // Mark
59 | rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK - MARK_EXCESS;
60 | Serial.print(" m");
61 | }
62 | else {
63 | // Space
64 | rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK + MARK_EXCESS;
65 | Serial.print(" s");
66 | }
67 | Serial.print(rawCodes[i - 1], DEC);
68 | }
69 | Serial.println("");
70 | }
71 | else {
72 | if (codeType == NEC) {
73 | Serial.print("Received NEC: ");
74 | if (results->value == REPEAT) {
75 | // Don't record a NEC repeat value as that's useless.
76 | Serial.println("repeat; ignoring.");
77 | return;
78 | }
79 | }
80 | else if (codeType == SONY) {
81 | Serial.print("Received SONY: ");
82 | }
83 | else if (codeType == RC5) {
84 | Serial.print("Received RC5: ");
85 | }
86 | else if (codeType == RC6) {
87 | Serial.print("Received RC6: ");
88 | }
89 | else {
90 | Serial.print("Unexpected codeType ");
91 | Serial.print(codeType, DEC);
92 | Serial.println("");
93 | }
94 | Serial.println(results->value, HEX);
95 | codeValue = results->value;
96 | codeLen = results->bits;
97 | }
98 | }
99 |
100 | void sendCode(int repeat) {
101 | if (codeType == NEC) {
102 | if (repeat) {
103 | irsend.sendNEC(REPEAT, codeLen);
104 | Serial.println("Sent NEC repeat");
105 | }
106 | else {
107 | irsend.sendNEC(codeValue, codeLen);
108 | Serial.print("Sent NEC ");
109 | Serial.println(codeValue, HEX);
110 | }
111 | }
112 | else if (codeType == SONY) {
113 | irsend.sendSony(codeValue, codeLen);
114 | Serial.print("Sent Sony ");
115 | Serial.println(codeValue, HEX);
116 | }
117 | else if (codeType == RC5 || codeType == RC6) {
118 | if (!repeat) {
119 | // Flip the toggle bit for a new button press
120 | toggle = 1 - toggle;
121 | }
122 | // Put the toggle bit into the code to send
123 | codeValue = codeValue & ~(1 << (codeLen - 1));
124 | codeValue = codeValue | (toggle << (codeLen - 1));
125 | if (codeType == RC5) {
126 | Serial.print("Sent RC5 ");
127 | Serial.println(codeValue, HEX);
128 | irsend.sendRC5(codeValue, codeLen);
129 | }
130 | else {
131 | irsend.sendRC6(codeValue, codeLen);
132 | Serial.print("Sent RC6 ");
133 | Serial.println(codeValue, HEX);
134 | }
135 | }
136 | else if (codeType == UNKNOWN /* i.e. raw */) {
137 | // Assume 38 KHz
138 | irsend.sendRaw(rawCodes, codeLen, 38);
139 | Serial.println("Sent raw");
140 | }
141 | }
142 |
143 | int lastButtonState;
144 |
145 | void loop() {
146 | // If button pressed, send the code.
147 | int buttonState = digitalRead(BUTTON_PIN);
148 | if (lastButtonState == HIGH && buttonState == LOW) {
149 | Serial.println("Released");
150 | irrecv.enableIRIn(); // Re-enable receiver
151 | }
152 |
153 | if (buttonState) {
154 | Serial.println("Pressed, sending");
155 | digitalWrite(STATUS_PIN, HIGH);
156 | sendCode(lastButtonState == buttonState);
157 | digitalWrite(STATUS_PIN, LOW);
158 | delay(50); // Wait a bit between retransmissions
159 | }
160 | else if (irrecv.decode(&results)) {
161 | digitalWrite(STATUS_PIN, HIGH);
162 | storeCode(&results);
163 | irrecv.resume(); // resume receiver
164 | digitalWrite(STATUS_PIN, LOW);
165 | }
166 | lastButtonState = buttonState;
167 | }
168 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/examples/IRrecvDemo/IRrecvDemo.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
3 | * An IR detector/demodulator must be connected to the input RECV_PIN.
4 | * Version 0.1 July, 2009
5 | * Copyright 2009 Ken Shirriff
6 | * http://arcfn.com
7 | */
8 |
9 | #include
10 |
11 | int RECV_PIN = 11;
12 |
13 | IRrecv irrecv(RECV_PIN);
14 |
15 | decode_results results;
16 |
17 | void setup()
18 | {
19 | Serial.begin(9600);
20 | irrecv.enableIRIn(); // Start the receiver
21 | }
22 |
23 | void loop() {
24 | if (irrecv.decode(&results)) {
25 | Serial.println(results.value, HEX);
26 | irrecv.resume(); // Receive the next value
27 | }
28 | delay(100);
29 | }
30 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/examples/IRrecvDump/IRrecvDump.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * IRremote: IRrecvDump - dump details of IR codes with IRrecv
3 | * An IR detector/demodulator must be connected to the input RECV_PIN.
4 | * Version 0.1 July, 2009
5 | * Copyright 2009 Ken Shirriff
6 | * http://arcfn.com
7 | * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
8 | * LG added by Darryl Smith (based on the JVC protocol)
9 | */
10 |
11 | #include
12 |
13 | /*
14 | * Default is Arduino pin D11.
15 | * You can change this to another available Arduino Pin.
16 | * Your IR receiver should be connected to the pin defined here
17 | */
18 | int RECV_PIN = 11;
19 |
20 | IRrecv irrecv(RECV_PIN);
21 |
22 | decode_results results;
23 |
24 | void setup()
25 | {
26 | Serial.begin(9600);
27 | irrecv.enableIRIn(); // Start the receiver
28 | }
29 |
30 |
31 | void dump(decode_results *results) {
32 | // Dumps out the decode_results structure.
33 | // Call this after IRrecv::decode()
34 | int count = results->rawlen;
35 | if (results->decode_type == UNKNOWN) {
36 | Serial.print("Unknown encoding: ");
37 | }
38 | else if (results->decode_type == NEC) {
39 | Serial.print("Decoded NEC: ");
40 |
41 | }
42 | else if (results->decode_type == SONY) {
43 | Serial.print("Decoded SONY: ");
44 | }
45 | else if (results->decode_type == RC5) {
46 | Serial.print("Decoded RC5: ");
47 | }
48 | else if (results->decode_type == RC6) {
49 | Serial.print("Decoded RC6: ");
50 | }
51 | else if (results->decode_type == PANASONIC) {
52 | Serial.print("Decoded PANASONIC - Address: ");
53 | Serial.print(results->address, HEX);
54 | Serial.print(" Value: ");
55 | }
56 | else if (results->decode_type == LG) {
57 | Serial.print("Decoded LG: ");
58 | }
59 | else if (results->decode_type == JVC) {
60 | Serial.print("Decoded JVC: ");
61 | }
62 | else if (results->decode_type == AIWA_RC_T501) {
63 | Serial.print("Decoded AIWA RC T501: ");
64 | }
65 | else if (results->decode_type == WHYNTER) {
66 | Serial.print("Decoded Whynter: ");
67 | }
68 | Serial.print(results->value, HEX);
69 | Serial.print(" (");
70 | Serial.print(results->bits, DEC);
71 | Serial.println(" bits)");
72 | Serial.print("Raw (");
73 | Serial.print(count, DEC);
74 | Serial.print("): ");
75 |
76 | for (int i = 1; i < count; i++) {
77 | if (i & 1) {
78 | Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
79 | }
80 | else {
81 | Serial.write('-');
82 | Serial.print((unsigned long) results->rawbuf[i]*USECPERTICK, DEC);
83 | }
84 | Serial.print(" ");
85 | }
86 | Serial.println();
87 | }
88 |
89 | void loop() {
90 | if (irrecv.decode(&results)) {
91 | Serial.println(results.value, HEX);
92 | dump(&results);
93 | irrecv.resume(); // Receive the next value
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/examples/IRrelay/IRrelay.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
3 | * An IR detector/demodulator must be connected to the input RECV_PIN.
4 | * Version 0.1 July, 2009
5 | * Copyright 2009 Ken Shirriff
6 | * http://arcfn.com
7 | */
8 |
9 | #include
10 |
11 | int RECV_PIN = 11;
12 | int RELAY_PIN = 4;
13 |
14 | IRrecv irrecv(RECV_PIN);
15 | decode_results results;
16 |
17 | // Dumps out the decode_results structure.
18 | // Call this after IRrecv::decode()
19 | // void * to work around compiler issue
20 | //void dump(void *v) {
21 | // decode_results *results = (decode_results *)v
22 | void dump(decode_results *results) {
23 | int count = results->rawlen;
24 | if (results->decode_type == UNKNOWN) {
25 | Serial.println("Could not decode message");
26 | }
27 | else {
28 | if (results->decode_type == NEC) {
29 | Serial.print("Decoded NEC: ");
30 | }
31 | else if (results->decode_type == SONY) {
32 | Serial.print("Decoded SONY: ");
33 | }
34 | else if (results->decode_type == RC5) {
35 | Serial.print("Decoded RC5: ");
36 | }
37 | else if (results->decode_type == RC6) {
38 | Serial.print("Decoded RC6: ");
39 | }
40 | Serial.print(results->value, HEX);
41 | Serial.print(" (");
42 | Serial.print(results->bits, DEC);
43 | Serial.println(" bits)");
44 | }
45 | Serial.print("Raw (");
46 | Serial.print(count, DEC);
47 | Serial.print("): ");
48 |
49 | for (int i = 0; i < count; i++) {
50 | if ((i % 2) == 1) {
51 | Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
52 | }
53 | else {
54 | Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC);
55 | }
56 | Serial.print(" ");
57 | }
58 | Serial.println("");
59 | }
60 |
61 | void setup()
62 | {
63 | pinMode(RELAY_PIN, OUTPUT);
64 | pinMode(13, OUTPUT);
65 | Serial.begin(9600);
66 | irrecv.enableIRIn(); // Start the receiver
67 | }
68 |
69 | int on = 0;
70 | unsigned long last = millis();
71 |
72 | void loop() {
73 | if (irrecv.decode(&results)) {
74 | // If it's been at least 1/4 second since the last
75 | // IR received, toggle the relay
76 | if (millis() - last > 250) {
77 | on = !on;
78 | digitalWrite(RELAY_PIN, on ? HIGH : LOW);
79 | digitalWrite(13, on ? HIGH : LOW);
80 | dump(&results);
81 | }
82 | last = millis();
83 | irrecv.resume(); // Receive the next value
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/examples/IRsendDemo/IRsendDemo.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
3 | * An IR LED must be connected to Arduino PWM pin 3.
4 | * Version 0.1 July, 2009
5 | * Copyright 2009 Ken Shirriff
6 | * http://arcfn.com
7 | */
8 |
9 |
10 | #include
11 |
12 | IRsend irsend;
13 |
14 | void setup()
15 | {
16 | }
17 |
18 | void loop() {
19 | for (int i = 0; i < 3; i++) {
20 | irsend.sendSony(0xa90, 12);
21 | delay(40);
22 | }
23 | delay(5000); //5 second delay between each signal burst
24 | }
25 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/examples/IRsendRawDemo/IRsendRawDemo.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * IRremote: IRsendRawDemo - demonstrates sending IR codes with sendRaw
3 | * An IR LED must be connected to Arduino PWM pin 3.
4 | * Version 0.1 July, 2009
5 | * Copyright 2009 Ken Shirriff
6 | * http://arcfn.com
7 | *
8 | * IRsendRawDemo - added by AnalysIR (via www.AnalysIR.com), 24 August 2015
9 | *
10 | * This example shows how to send a RAW signal using the IRremote library.
11 | * The example signal is actually a 32 bit NEC signal.
12 | * Remote Control button: LGTV Power On/Off.
13 | * Hex Value: 0x20DF10EF, 32 bits
14 | *
15 | * It is more efficient to use the sendNEC function to send NEC signals.
16 | * Use of sendRaw here, serves only as an example of using the function.
17 | *
18 | */
19 |
20 |
21 | #include
22 |
23 | IRsend irsend;
24 |
25 | void setup()
26 | {
27 |
28 | }
29 |
30 | void loop() {
31 | int khz = 38; // 38kHz carrier frequency for the NEC protocol
32 | unsigned int irSignal[] = {9000, 4500, 560, 560, 560, 560, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 39416, 9000, 2210, 560}; //AnalysIR Batch Export (IRremote) - RAW
33 |
34 | irsend.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz); //Note the approach used to automatically calculate the size of the array.
35 |
36 | delay(5000); //In this example, the signal will be repeated every 5 seconds, approximately.
37 | }
38 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/examples/IRtest/IRtest.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * IRremote: IRtest unittest
3 | * Version 0.1 July, 2009
4 | * Copyright 2009 Ken Shirriff
5 | * http://arcfn.com
6 | *
7 | * Note: to run these tests, edit IRremote/IRremote.h to add "#define TEST"
8 | * You must then recompile the library by removing IRremote.o and restarting
9 | * the arduino IDE.
10 | */
11 |
12 | #include
13 | #include
14 |
15 | // Dumps out the decode_results structure.
16 | // Call this after IRrecv::decode()
17 | // void * to work around compiler issue
18 | //void dump(void *v) {
19 | // decode_results *results = (decode_results *)v
20 | void dump(decode_results *results) {
21 | int count = results->rawlen;
22 | if (results->decode_type == UNKNOWN) {
23 | Serial.println("Could not decode message");
24 | }
25 | else {
26 | if (results->decode_type == NEC) {
27 | Serial.print("Decoded NEC: ");
28 | }
29 | else if (results->decode_type == SONY) {
30 | Serial.print("Decoded SONY: ");
31 | }
32 | else if (results->decode_type == RC5) {
33 | Serial.print("Decoded RC5: ");
34 | }
35 | else if (results->decode_type == RC6) {
36 | Serial.print("Decoded RC6: ");
37 | }
38 | Serial.print(results->value, HEX);
39 | Serial.print(" (");
40 | Serial.print(results->bits, DEC);
41 | Serial.println(" bits)");
42 | }
43 | Serial.print("Raw (");
44 | Serial.print(count, DEC);
45 | Serial.print("): ");
46 |
47 | for (int i = 0; i < count; i++) {
48 | if ((i % 2) == 1) {
49 | Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
50 | }
51 | else {
52 | Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC);
53 | }
54 | Serial.print(" ");
55 | }
56 | Serial.println("");
57 | }
58 |
59 | IRrecv irrecv(0);
60 | decode_results results;
61 |
62 | class IRsendDummy :
63 | public IRsend
64 | {
65 | public:
66 | // For testing, just log the marks/spaces
67 | #define SENDLOG_LEN 128
68 | int sendlog[SENDLOG_LEN];
69 | int sendlogcnt;
70 | IRsendDummy() :
71 | IRsend() {
72 | }
73 | void reset() {
74 | sendlogcnt = 0;
75 | }
76 | void mark(int time) {
77 | sendlog[sendlogcnt] = time;
78 | if (sendlogcnt < SENDLOG_LEN) sendlogcnt++;
79 | }
80 | void space(int time) {
81 | sendlog[sendlogcnt] = -time;
82 | if (sendlogcnt < SENDLOG_LEN) sendlogcnt++;
83 | }
84 | // Copies the dummy buf into the interrupt buf
85 | void useDummyBuf() {
86 | int last = SPACE;
87 | irparams.rcvstate = STATE_STOP;
88 | irparams.rawlen = 1; // Skip the gap
89 | for (int i = 0 ; i < sendlogcnt; i++) {
90 | if (sendlog[i] < 0) {
91 | if (last == MARK) {
92 | // New space
93 | irparams.rawbuf[irparams.rawlen++] = (-sendlog[i] - MARK_EXCESS) / USECPERTICK;
94 | last = SPACE;
95 | }
96 | else {
97 | // More space
98 | irparams.rawbuf[irparams.rawlen - 1] += -sendlog[i] / USECPERTICK;
99 | }
100 | }
101 | else if (sendlog[i] > 0) {
102 | if (last == SPACE) {
103 | // New mark
104 | irparams.rawbuf[irparams.rawlen++] = (sendlog[i] + MARK_EXCESS) / USECPERTICK;
105 | last = MARK;
106 | }
107 | else {
108 | // More mark
109 | irparams.rawbuf[irparams.rawlen - 1] += sendlog[i] / USECPERTICK;
110 | }
111 | }
112 | }
113 | if (irparams.rawlen % 2) {
114 | irparams.rawlen--; // Remove trailing space
115 | }
116 | }
117 | };
118 |
119 | IRsendDummy irsenddummy;
120 |
121 | void verify(unsigned long val, int bits, int type) {
122 | irsenddummy.useDummyBuf();
123 | irrecv.decode(&results);
124 | Serial.print("Testing ");
125 | Serial.print(val, HEX);
126 | if (results.value == val && results.bits == bits && results.decode_type == type) {
127 | Serial.println(": OK");
128 | }
129 | else {
130 | Serial.println(": Error");
131 | dump(&results);
132 | }
133 | }
134 |
135 | void testNEC(unsigned long val, int bits) {
136 | irsenddummy.reset();
137 | irsenddummy.sendNEC(val, bits);
138 | verify(val, bits, NEC);
139 | }
140 | void testSony(unsigned long val, int bits) {
141 | irsenddummy.reset();
142 | irsenddummy.sendSony(val, bits);
143 | verify(val, bits, SONY);
144 | }
145 | void testRC5(unsigned long val, int bits) {
146 | irsenddummy.reset();
147 | irsenddummy.sendRC5(val, bits);
148 | verify(val, bits, RC5);
149 | }
150 | void testRC6(unsigned long val, int bits) {
151 | irsenddummy.reset();
152 | irsenddummy.sendRC6(val, bits);
153 | verify(val, bits, RC6);
154 | }
155 |
156 | void test() {
157 | Serial.println("NEC tests");
158 | testNEC(0x00000000, 32);
159 | testNEC(0xffffffff, 32);
160 | testNEC(0xaaaaaaaa, 32);
161 | testNEC(0x55555555, 32);
162 | testNEC(0x12345678, 32);
163 | Serial.println("Sony tests");
164 | testSony(0xfff, 12);
165 | testSony(0x000, 12);
166 | testSony(0xaaa, 12);
167 | testSony(0x555, 12);
168 | testSony(0x123, 12);
169 | Serial.println("RC5 tests");
170 | testRC5(0xfff, 12);
171 | testRC5(0x000, 12);
172 | testRC5(0xaaa, 12);
173 | testRC5(0x555, 12);
174 | testRC5(0x123, 12);
175 | Serial.println("RC6 tests");
176 | testRC6(0xfffff, 20);
177 | testRC6(0x00000, 20);
178 | testRC6(0xaaaaa, 20);
179 | testRC6(0x55555, 20);
180 | testRC6(0x12345, 20);
181 | }
182 |
183 | void setup()
184 | {
185 | Serial.begin(9600);
186 | test();
187 | }
188 |
189 | void loop() {
190 | }
191 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/examples/JVCPanasonicSendDemo/JVCPanasonicSendDemo.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
3 | * An IR LED must be connected to Arduino PWM pin 3.
4 | * Version 0.1 July, 2009
5 | * Copyright 2009 Ken Shirriff
6 | * http://arcfn.com
7 | * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
8 | */
9 | #include
10 |
11 | #define PanasonicAddress 0x4004 // Panasonic address (Pre data)
12 | #define PanasonicPower 0x100BCBD // Panasonic Power button
13 |
14 | #define JVCPower 0xC5E8
15 |
16 | IRsend irsend;
17 |
18 | void setup()
19 | {
20 | }
21 |
22 | void loop() {
23 | irsend.sendPanasonic(PanasonicAddress,PanasonicPower); // This should turn your TV on and off
24 |
25 | irsend.sendJVC(JVCPower, 16,0); // hex value, 16 bits, no repeat
26 | delayMicroseconds(50); // see http://www.sbprojects.com/knowledge/ir/jvc.php for information
27 | irsend.sendJVC(JVCPower, 16,1); // hex value, 16 bits, repeat
28 | delayMicroseconds(50);
29 | }
30 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/examples/LGACSendDemo/LGACSendDemo.md:
--------------------------------------------------------------------------------
1 | === decoding for LG A/C ====
2 | - 1) remote of LG AC has two type of HDR mark/space, 8000/4000 and 3100/10000
3 | - 2) HDR 8000/4000 is decoded using decodeLG(IRrecvDumpV2) without problem
4 | - 3) for HDR 3100/10000, use AnalysIR's code : http://www.analysir.com/blog/2014/03/19/air-conditioners-problems-recording-long-infrared-remote-control-signals-arduino/
5 | - 4) for bin output based on AnalysIR's code : https://gist.github.com/chaeplin/a3a4b4b6b887c663bfe8
6 | - 5) remove first two byte(11)
7 | - 6) sample rawcode with bin output : https://gist.github.com/chaeplin/134d232e0b8cfb898860
8 |
9 |
10 | === *** ===
11 | - 1) Sample raw code : https://gist.github.com/chaeplin/ab2a7ad1533c41260f0d
12 | - 2) send raw code : https://gist.github.com/chaeplin/7c800d3166463bb51be4
13 |
14 |
15 | === *** ===
16 | - (0) : Cooling or Heating
17 | - (1) : fixed
18 | - (2) : fixed
19 | - (3) : special(power, swing, air clean)
20 | - (4) : change air flow, temperature, cooling(0)/heating(4)
21 | - (5) : temperature ( 15 + (5) = )
22 | - (6) : air flow
23 | - (7) : crc ( 3 + 4 + 5 + 6 ) & B00001111
24 |
25 |
26 | °F = °C × 1.8 + 32
27 | °C = (°F − 32) / 1.8
28 |
29 |
30 | === *** ===
31 | * remote / Korea / without heating
32 |
33 | | status |(0)| (1)| (2)| (3)| (4)| (5)| (6)| (7)
34 | |----------------|---|----|----|----|----|----|----|----
35 | | on / 25 / mid | C |1000|1000|0000|0000|1010|0010|1100
36 | | on / 26 / mid | C |1000|1000|0000|0000|1011|0010|1101
37 | | on / 27 / mid | C |1000|1000|0000|0000|1100|0010|1110
38 | | on / 28 / mid | C |1000|1000|0000|0000|1101|0010|1111
39 | | on / 25 / high | C |1000|1000|0000|0000|1010|0100|1110
40 | | on / 26 / high | C |1000|1000|0000|0000|1011|0100|1111
41 | | on / 27 / high | C |1000|1000|0000|0000|1100|0100|0000
42 | | on / 28 / high | C |1000|1000|0000|0000|1101|0100|0001
43 | |----------------|---|----|----|----|----|----|----|----
44 | | 1 up | C |1000|1000|0000|1000|1101|0100|1001
45 | |----------------|---|----|----|----|----|----|----|----
46 | | Cool power | C |1000|1000|0001|0000|0000|1100|1101
47 | | energy saving | C |1000|1000|0001|0000|0000|0100|0101
48 | | power | C |1000|1000|0001|0000|0000|1000|1001
49 | | flow/up/down | C |1000|1000|0001|0011|0001|0100|1001
50 | | up/down off | C |1000|1000|0001|0011|0001|0101|1010
51 | | flow/left/right| C |1000|1000|0001|0011|0001|0110|1011
52 | | left/right off | C |1000|1000|0001|0011|0001|0111|1100
53 | |----------------|---|----|----|----|----|----|----|----
54 | | Air clean | C |1000|1000|1100|0000|0000|0000|1100
55 | |----------------|---|----|----|----|----|----|----|----
56 | | off | C |1000|1000|1100|0000|0000|0101|0001
57 |
58 |
59 |
60 | * remote / with heating
61 | * converted using raw code at https://github.com/chaeplin/RaspAC/blob/master/lircd.conf
62 |
63 | | status |(0)| (1)| (2)| (3)| (4)| (5)| (6)| (7)
64 | |----------------|---|----|----|----|----|----|----|----
65 | | on | C |1000|1000|0000|0000|1011|0010|1101
66 | |----------------|---|----|----|----|----|----|----|----
67 | | off | C |1000|1000|1100|0000|0000|0101|0001
68 | |----------------|---|----|----|----|----|----|----|----
69 | | 64 / 18 | C |1000|1000|0000|0000|0011|0100|0111
70 | | 66 / 19 | C |1000|1000|0000|0000|0100|0100|1000
71 | | 68 / 20 | C |1000|1000|0000|0000|0101|0100|1001
72 | | 70 / 21 | C |1000|1000|0000|0000|0110|0100|1010
73 | | 72 / 22 | C |1000|1000|0000|0000|0111|0100|1011
74 | | 74 / 23 | C |1000|1000|0000|0000|1000|0100|1100
75 | | 76 / 25 | C |1000|1000|0000|0000|1010|0100|1110
76 | | 78 / 26 | C |1000|1000|0000|0000|1011|0100|1111
77 | | 80 / 27 | C |1000|1000|0000|0000|1100|0100|0000
78 | | 82 / 28 | C |1000|1000|0000|0000|1101|0100|0001
79 | | 84 / 29 | C |1000|1000|0000|0000|1110|0100|0010
80 | | 86 / 30 | C |1000|1000|0000|0000|1111|0100|0011
81 | |----------------|---|----|----|----|----|----|----|----
82 | | heat64 | H |1000|1000|0000|0100|0011|0100|1011
83 | | heat66 | H |1000|1000|0000|0100|0100|0100|1100
84 | | heat68 | H |1000|1000|0000|0100|0101|0100|1101
85 | | heat70 | H |1000|1000|0000|0100|0110|0100|1110
86 | | heat72 | H |1000|1000|0000|0100|0111|0100|1111
87 | | heat74 | H |1000|1000|0000|0100|1000|0100|0000
88 | | heat76 | H |1000|1000|0000|0100|1001|0100|0001
89 | | heat78 | H |1000|1000|0000|0100|1011|0100|0011
90 | | heat80 | H |1000|1000|0000|0100|1100|0100|0100
91 | | heat82 | H |1000|1000|0000|0100|1101|0100|0101
92 | | heat84 | H |1000|1000|0000|0100|1110|0100|0110
93 | | heat86 | H |1000|1000|0000|0100|1111|0100|0111
94 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/irSend.cpp:
--------------------------------------------------------------------------------
1 | #include "IRremote.h"
2 | #include "IRremoteInt.h"
3 |
4 | //+=============================================================================
5 | void IRsend::sendRaw (unsigned int buf[], unsigned int len, unsigned int hz)
6 | {
7 | // Set IR carrier frequency
8 | enableIROut(hz);
9 |
10 | for (unsigned int i = 0; i < len; i++) {
11 | if (i & 1) space(buf[i]) ;
12 | else mark (buf[i]) ;
13 | }
14 |
15 | space(0); // Always end with the LED off
16 | }
17 |
18 | //+=============================================================================
19 | // Sends an IR mark for the specified number of microseconds.
20 | // The mark output is modulated at the PWM frequency.
21 | //
22 | void IRsend::mark (unsigned int time)
23 | {
24 | TIMER_ENABLE_PWM; // Enable pin 3 PWM output
25 | if (time > 0) custom_delay_usec(time);
26 | }
27 |
28 | //+=============================================================================
29 | // Leave pin off for time (given in microseconds)
30 | // Sends an IR space for the specified number of microseconds.
31 | // A space is no output, so the PWM output is disabled.
32 | //
33 | void IRsend::space (unsigned int time)
34 | {
35 | TIMER_DISABLE_PWM; // Disable pin 3 PWM output
36 | if (time > 0) IRsend::custom_delay_usec(time);
37 | }
38 |
39 |
40 |
41 |
42 |
43 | //+=============================================================================
44 | // Enables IR output. The khz value controls the modulation frequency in kilohertz.
45 | // The IR output will be on pin 3 (OC2B).
46 | // This routine is designed for 36-40KHz; if you use it for other values, it's up to you
47 | // to make sure it gives reasonable results. (Watch out for overflow / underflow / rounding.)
48 | // TIMER2 is used in phase-correct PWM mode, with OCR2A controlling the frequency and OCR2B
49 | // controlling the duty cycle.
50 | // There is no prescaling, so the output frequency is 16MHz / (2 * OCR2A)
51 | // To turn the output on and off, we leave the PWM running, but connect and disconnect the output pin.
52 | // A few hours staring at the ATmega documentation and this will all make sense.
53 | // See my Secrets of Arduino PWM at http://arcfn.com/2009/07/secrets-of-arduino-pwm.html for details.
54 | //
55 | void IRsend::enableIROut (int khz)
56 | {
57 | // Disable the Timer2 Interrupt (which is used for receiving IR)
58 | TIMER_DISABLE_INTR; //Timer2 Overflow Interrupt
59 |
60 | pinMode(TIMER_PWM_PIN, OUTPUT);
61 | digitalWrite(TIMER_PWM_PIN, LOW); // When not sending PWM, we want it low
62 |
63 | // COM2A = 00: disconnect OC2A
64 | // COM2B = 00: disconnect OC2B; to send signal set to 10: OC2B non-inverted
65 | // WGM2 = 101: phase-correct PWM with OCRA as top
66 | // CS2 = 000: no prescaling
67 | // The top value for the timer. The modulation frequency will be SYSCLOCK / 2 / OCR2A.
68 | TIMER_CONFIG_KHZ(khz);
69 | }
70 |
71 | //+=============================================================================
72 | // Custom delay function that circumvents Arduino's delayMicroseconds limit
73 |
74 | void IRsend::custom_delay_usec(unsigned long uSecs) {
75 | if (uSecs > 4) {
76 | unsigned long start = micros();
77 | unsigned long endMicros = start + uSecs - 4;
78 | if (endMicros < start) { // Check if overflow
79 | while ( micros() > start ) {} // wait until overflow
80 | }
81 | while ( micros() < endMicros ) {} // normal wait
82 | }
83 | //else {
84 | // __asm__("nop\n\t"); // must have or compiler optimizes out
85 | //}
86 | }
87 |
88 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/ir_Aiwa.cpp:
--------------------------------------------------------------------------------
1 | #include "IRremote.h"
2 | #include "IRremoteInt.h"
3 |
4 | //==============================================================================
5 | // AAA IIIII W W AAA
6 | // A A I W W A A
7 | // AAAAA I W W W AAAAA
8 | // A A I W W W A A
9 | // A A IIIII WWW A A
10 | //==============================================================================
11 |
12 | // Based off the RC-T501 RCU
13 | // Lirc file http://lirc.sourceforge.net/remotes/aiwa/RC-T501
14 |
15 | #define AIWA_RC_T501_HZ 38
16 | #define AIWA_RC_T501_BITS 15
17 | #define AIWA_RC_T501_PRE_BITS 26
18 | #define AIWA_RC_T501_POST_BITS 1
19 | #define AIWA_RC_T501_SUM_BITS (AIWA_RC_T501_PRE_BITS + AIWA_RC_T501_BITS + AIWA_RC_T501_POST_BITS)
20 | #define AIWA_RC_T501_HDR_MARK 8800
21 | #define AIWA_RC_T501_HDR_SPACE 4500
22 | #define AIWA_RC_T501_BIT_MARK 500
23 | #define AIWA_RC_T501_ONE_SPACE 600
24 | #define AIWA_RC_T501_ZERO_SPACE 1700
25 |
26 | //+=============================================================================
27 | #if SEND_AIWA_RC_T501
28 | void IRsend::sendAiwaRCT501 (int code)
29 | {
30 | unsigned long pre = 0x0227EEC0; // 26-bits
31 |
32 | // Set IR carrier frequency
33 | enableIROut(AIWA_RC_T501_HZ);
34 |
35 | // Header
36 | mark(AIWA_RC_T501_HDR_MARK);
37 | space(AIWA_RC_T501_HDR_SPACE);
38 |
39 | // Send "pre" data
40 | for (unsigned long mask = 1UL << (26 - 1); mask; mask >>= 1) {
41 | mark(AIWA_RC_T501_BIT_MARK);
42 | if (pre & mask) space(AIWA_RC_T501_ONE_SPACE) ;
43 | else space(AIWA_RC_T501_ZERO_SPACE) ;
44 | }
45 |
46 | //-v- THIS CODE LOOKS LIKE IT MIGHT BE WRONG - CHECK!
47 | // it only send 15bits and ignores the top bit
48 | // then uses TOPBIT which is 0x80000000 to check the bit code
49 | // I suspect TOPBIT should be changed to 0x00008000
50 |
51 | // Skip first code bit
52 | code <<= 1;
53 | // Send code
54 | for (int i = 0; i < 15; i++) {
55 | mark(AIWA_RC_T501_BIT_MARK);
56 | if (code & 0x80000000) space(AIWA_RC_T501_ONE_SPACE) ;
57 | else space(AIWA_RC_T501_ZERO_SPACE) ;
58 | code <<= 1;
59 | }
60 |
61 | //-^- THIS CODE LOOKS LIKE IT MIGHT BE WRONG - CHECK!
62 |
63 | // POST-DATA, 1 bit, 0x0
64 | mark(AIWA_RC_T501_BIT_MARK);
65 | space(AIWA_RC_T501_ZERO_SPACE);
66 |
67 | mark(AIWA_RC_T501_BIT_MARK);
68 | space(0);
69 | }
70 | #endif
71 |
72 | //+=============================================================================
73 | #if DECODE_AIWA_RC_T501
74 | bool IRrecv::decodeAiwaRCT501 (decode_results *results)
75 | {
76 | int data = 0;
77 | int offset = 1;
78 |
79 | // Check SIZE
80 | if (irparams.rawlen < 2 * (AIWA_RC_T501_SUM_BITS) + 4) return false ;
81 |
82 | // Check HDR Mark/Space
83 | if (!MATCH_MARK (results->rawbuf[offset++], AIWA_RC_T501_HDR_MARK )) return false ;
84 | if (!MATCH_SPACE(results->rawbuf[offset++], AIWA_RC_T501_HDR_SPACE)) return false ;
85 |
86 | offset += 26; // skip pre-data - optional
87 | while(offset < irparams.rawlen - 4) {
88 | if (MATCH_MARK(results->rawbuf[offset], AIWA_RC_T501_BIT_MARK)) offset++ ;
89 | else return false ;
90 |
91 | // ONE & ZERO
92 | if (MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_ONE_SPACE)) data = (data << 1) | 1 ;
93 | else if (MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_ZERO_SPACE)) data = (data << 1) | 0 ;
94 | else break ; // End of one & zero detected
95 | offset++;
96 | }
97 |
98 | results->bits = (offset - 1) / 2;
99 | if (results->bits < 42) return false ;
100 |
101 | results->value = data;
102 | results->decode_type = AIWA_RC_T501;
103 | return true;
104 | }
105 | #endif
106 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/ir_Denon.cpp:
--------------------------------------------------------------------------------
1 | #include "IRremote.h"
2 | #include "IRremoteInt.h"
3 |
4 | // Reverse Engineered by looking at RAW dumps generated by IRremote
5 |
6 | // I have since discovered that Denon publish all their IR codes:
7 | // https://www.google.co.uk/search?q=DENON+MASTER+IR+Hex+Command+Sheet
8 | // -> http://assets.denon.com/documentmaster/us/denon%20master%20ir%20hex.xls
9 |
10 | // Having looked at the official Denon Pronto sheet and reverse engineered
11 | // the timing values from it, it is obvious that Denon have a range of
12 | // different timings and protocols ...the values here work for my AVR-3801 Amp!
13 |
14 | //==============================================================================
15 | // DDDD EEEEE N N OOO N N
16 | // D D E NN N O O NN N
17 | // D D EEE N N N O O N N N
18 | // D D E N NN O O N NN
19 | // DDDD EEEEE N N OOO N N
20 | //==============================================================================
21 |
22 | #define BITS 14 // The number of bits in the command
23 |
24 | #define HDR_MARK 300 // The length of the Header:Mark
25 | #define HDR_SPACE 750 // The lenght of the Header:Space
26 |
27 | #define BIT_MARK 300 // The length of a Bit:Mark
28 | #define ONE_SPACE 1800 // The length of a Bit:Space for 1's
29 | #define ZERO_SPACE 750 // The length of a Bit:Space for 0's
30 |
31 | //+=============================================================================
32 | //
33 | #if SEND_DENON
34 | void IRsend::sendDenon (unsigned long data, int nbits)
35 | {
36 | // Set IR carrier frequency
37 | enableIROut(38);
38 |
39 | // Header
40 | mark (HDR_MARK);
41 | space(HDR_SPACE);
42 |
43 | // Data
44 | for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) {
45 | if (data & mask) {
46 | mark (BIT_MARK);
47 | space(ONE_SPACE);
48 | } else {
49 | mark (BIT_MARK);
50 | space(ZERO_SPACE);
51 | }
52 | }
53 |
54 | // Footer
55 | mark(BIT_MARK);
56 | space(0); // Always end with the LED off
57 | }
58 | #endif
59 |
60 | //+=============================================================================
61 | //
62 | #if DECODE_DENON
63 | bool IRrecv::decodeDenon (decode_results *results)
64 | {
65 | unsigned long data = 0; // Somewhere to build our code
66 | int offset = 1; // Skip the Gap reading
67 |
68 | // Check we have the right amount of data
69 | if (irparams.rawlen != 1 + 2 + (2 * BITS) + 1) return false ;
70 |
71 | // Check initial Mark+Space match
72 | if (!MATCH_MARK (results->rawbuf[offset++], HDR_MARK )) return false ;
73 | if (!MATCH_SPACE(results->rawbuf[offset++], HDR_SPACE)) return false ;
74 |
75 | // Read the bits in
76 | for (int i = 0; i < BITS; i++) {
77 | // Each bit looks like: MARK + SPACE_1 -> 1
78 | // or : MARK + SPACE_0 -> 0
79 | if (!MATCH_MARK(results->rawbuf[offset++], BIT_MARK)) return false ;
80 |
81 | // IR data is big-endian, so we shuffle it in from the right:
82 | if (MATCH_SPACE(results->rawbuf[offset], ONE_SPACE)) data = (data << 1) | 1 ;
83 | else if (MATCH_SPACE(results->rawbuf[offset], ZERO_SPACE)) data = (data << 1) | 0 ;
84 | else return false ;
85 | offset++;
86 | }
87 |
88 | // Success
89 | results->bits = BITS;
90 | results->value = data;
91 | results->decode_type = DENON;
92 | return true;
93 | }
94 | #endif
95 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/ir_Dish.cpp:
--------------------------------------------------------------------------------
1 | #include "IRremote.h"
2 | #include "IRremoteInt.h"
3 |
4 | //==============================================================================
5 | // DDDD IIIII SSSS H H
6 | // D D I S H H
7 | // D D I SSS HHHHH
8 | // D D I S H H
9 | // DDDD IIIII SSSS H H
10 | //==============================================================================
11 |
12 | // Sharp and DISH support by Todd Treece ( http://unionbridge.org/design/ircommand )
13 | //
14 | // The sned function needs to be repeated 4 times
15 | //
16 | // Only send the last for characters of the hex.
17 | // I.E. Use 0x1C10 instead of 0x0000000000001C10 as listed in the LIRC file.
18 | //
19 | // Here is the LIRC file I found that seems to match the remote codes from the
20 | // oscilloscope:
21 | // DISH NETWORK (echostar 301):
22 | // http://lirc.sourceforge.net/remotes/echostar/301_501_3100_5100_58xx_59xx
23 |
24 | #define DISH_BITS 16
25 | #define DISH_HDR_MARK 400
26 | #define DISH_HDR_SPACE 6100
27 | #define DISH_BIT_MARK 400
28 | #define DISH_ONE_SPACE 1700
29 | #define DISH_ZERO_SPACE 2800
30 | #define DISH_RPT_SPACE 6200
31 |
32 | //+=============================================================================
33 | #if SEND_DISH
34 | void IRsend::sendDISH (unsigned long data, int nbits)
35 | {
36 | // Set IR carrier frequency
37 | enableIROut(56);
38 |
39 | mark(DISH_HDR_MARK);
40 | space(DISH_HDR_SPACE);
41 |
42 | for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) {
43 | if (data & mask) {
44 | mark(DISH_BIT_MARK);
45 | space(DISH_ONE_SPACE);
46 | } else {
47 | mark(DISH_BIT_MARK);
48 | space(DISH_ZERO_SPACE);
49 | }
50 | }
51 | }
52 | #endif
53 |
54 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/ir_JVC.cpp:
--------------------------------------------------------------------------------
1 | #include "IRremote.h"
2 | #include "IRremoteInt.h"
3 |
4 | //==============================================================================
5 | // JJJJJ V V CCCC
6 | // J V V C
7 | // J V V C
8 | // J J V V C
9 | // J V CCCC
10 | //==============================================================================
11 |
12 | #define JVC_BITS 16
13 | #define JVC_HDR_MARK 8000
14 | #define JVC_HDR_SPACE 4000
15 | #define JVC_BIT_MARK 600
16 | #define JVC_ONE_SPACE 1600
17 | #define JVC_ZERO_SPACE 550
18 | #define JVC_RPT_LENGTH 60000
19 |
20 | //+=============================================================================
21 | // JVC does NOT repeat by sending a separate code (like NEC does).
22 | // The JVC protocol repeats by skipping the header.
23 | // To send a JVC repeat signal, send the original code value
24 | // and set 'repeat' to true
25 | //
26 | #if SEND_JVC
27 | void IRsend::sendJVC (unsigned long data, int nbits, bool repeat)
28 | {
29 | // Set IR carrier frequency
30 | enableIROut(38);
31 |
32 | // Only send the Header if this is NOT a repeat command
33 | if (!repeat){
34 | mark(JVC_HDR_MARK);
35 | space(JVC_HDR_SPACE);
36 | }
37 |
38 | // Data
39 | for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) {
40 | if (data & mask) {
41 | mark(JVC_BIT_MARK);
42 | space(JVC_ONE_SPACE);
43 | } else {
44 | mark(JVC_BIT_MARK);
45 | space(JVC_ZERO_SPACE);
46 | }
47 | }
48 |
49 | // Footer
50 | mark(JVC_BIT_MARK);
51 | space(0); // Always end with the LED off
52 | }
53 | #endif
54 |
55 | //+=============================================================================
56 | #if DECODE_JVC
57 | bool IRrecv::decodeJVC (decode_results *results)
58 | {
59 | long data = 0;
60 | int offset = 1; // Skip first space
61 |
62 | // Check for repeat
63 | if ( (irparams.rawlen - 1 == 33)
64 | && MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK)
65 | && MATCH_MARK(results->rawbuf[irparams.rawlen-1], JVC_BIT_MARK)
66 | ) {
67 | results->bits = 0;
68 | results->value = REPEAT;
69 | results->decode_type = JVC;
70 | return true;
71 | }
72 |
73 | // Initial mark
74 | if (!MATCH_MARK(results->rawbuf[offset++], JVC_HDR_MARK)) return false ;
75 |
76 | if (irparams.rawlen < (2 * JVC_BITS) + 1 ) return false ;
77 |
78 | // Initial space
79 | if (!MATCH_SPACE(results->rawbuf[offset++], JVC_HDR_SPACE)) return false ;
80 |
81 | for (int i = 0; i < JVC_BITS; i++) {
82 | if (!MATCH_MARK(results->rawbuf[offset++], JVC_BIT_MARK)) return false ;
83 |
84 | if (MATCH_SPACE(results->rawbuf[offset], JVC_ONE_SPACE)) data = (data << 1) | 1 ;
85 | else if (MATCH_SPACE(results->rawbuf[offset], JVC_ZERO_SPACE)) data = (data << 1) | 0 ;
86 | else return false ;
87 | offset++;
88 | }
89 |
90 | // Stop bit
91 | if (!MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK)) return false ;
92 |
93 | // Success
94 | results->bits = JVC_BITS;
95 | results->value = data;
96 | results->decode_type = JVC;
97 |
98 | return true;
99 | }
100 | #endif
101 |
102 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/ir_LG.cpp:
--------------------------------------------------------------------------------
1 | #include "IRremote.h"
2 | #include "IRremoteInt.h"
3 |
4 | //==============================================================================
5 | // L GGGG
6 | // L G
7 | // L G GG
8 | // L G G
9 | // LLLLL GGG
10 | //==============================================================================
11 |
12 | #define LG_BITS 28
13 |
14 | #define LG_HDR_MARK 8000
15 | #define LG_HDR_SPACE 4000
16 | #define LG_BIT_MARK 600
17 | #define LG_ONE_SPACE 1600
18 | #define LG_ZERO_SPACE 550
19 | #define LG_RPT_LENGTH 60000
20 |
21 | //+=============================================================================
22 | #if DECODE_LG
23 | bool IRrecv::decodeLG (decode_results *results)
24 | {
25 | long data = 0;
26 | int offset = 1; // Skip first space
27 |
28 | // Check we have the right amount of data
29 | if (irparams.rawlen < (2 * LG_BITS) + 1 ) return false ;
30 |
31 | // Initial mark/space
32 | if (!MATCH_MARK(results->rawbuf[offset++], LG_HDR_MARK)) return false ;
33 | if (!MATCH_SPACE(results->rawbuf[offset++], LG_HDR_SPACE)) return false ;
34 |
35 | for (int i = 0; i < LG_BITS; i++) {
36 | if (!MATCH_MARK(results->rawbuf[offset++], LG_BIT_MARK)) return false ;
37 |
38 | if (MATCH_SPACE(results->rawbuf[offset], LG_ONE_SPACE)) data = (data << 1) | 1 ;
39 | else if (MATCH_SPACE(results->rawbuf[offset], LG_ZERO_SPACE)) data = (data << 1) | 0 ;
40 | else return false ;
41 | offset++;
42 | }
43 |
44 | // Stop bit
45 | if (!MATCH_MARK(results->rawbuf[offset], LG_BIT_MARK)) return false ;
46 |
47 | // Success
48 | results->bits = LG_BITS;
49 | results->value = data;
50 | results->decode_type = LG;
51 | return true;
52 | }
53 | #endif
54 |
55 | //+=============================================================================
56 | #if SEND_LG
57 | void IRsend::sendLG (unsigned long data, int nbits)
58 | {
59 | // Set IR carrier frequency
60 | enableIROut(38);
61 |
62 | // Header
63 | mark(LG_HDR_MARK);
64 | space(LG_HDR_SPACE);
65 | mark(LG_BIT_MARK);
66 |
67 | // Data
68 | for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) {
69 | if (data & mask) {
70 | space(LG_ONE_SPACE);
71 | mark(LG_BIT_MARK);
72 | } else {
73 | space(LG_ZERO_SPACE);
74 | mark(LG_BIT_MARK);
75 | }
76 | }
77 | space(0); // Always end with the LED off
78 | }
79 | #endif
80 |
81 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/ir_Mitsubishi.cpp:
--------------------------------------------------------------------------------
1 | #include "IRremote.h"
2 | #include "IRremoteInt.h"
3 |
4 | //==============================================================================
5 | // MMMMM IIIII TTTTT SSSS U U BBBB IIIII SSSS H H IIIII
6 | // M M M I T S U U B B I S H H I
7 | // M M M I T SSS U U BBBB I SSS HHHHH I
8 | // M M I T S U U B B I S H H I
9 | // M M IIIII T SSSS UUU BBBBB IIIII SSSS H H IIIII
10 | //==============================================================================
11 |
12 | // Looks like Sony except for timings, 48 chars of data and time/space different
13 |
14 | #define MITSUBISHI_BITS 16
15 |
16 | // Mitsubishi RM 75501
17 | // 14200 7 41 7 42 7 42 7 17 7 17 7 18 7 41 7 18 7 17 7 17 7 18 7 41 8 17 7 17 7 18 7 17 7
18 | // #define MITSUBISHI_HDR_MARK 250 // seen range 3500
19 | #define MITSUBISHI_HDR_SPACE 350 // 7*50+100
20 | #define MITSUBISHI_ONE_MARK 1950 // 41*50-100
21 | #define MITSUBISHI_ZERO_MARK 750 // 17*50-100
22 | // #define MITSUBISHI_DOUBLE_SPACE_USECS 800 // usually ssee 713 - not using ticks as get number wrapround
23 | // #define MITSUBISHI_RPT_LENGTH 45000
24 |
25 | //+=============================================================================
26 | #if DECODE_MITSUBISHI
27 | bool IRrecv::decodeMitsubishi (decode_results *results)
28 | {
29 | // Serial.print("?!? decoding Mitsubishi:");Serial.print(irparams.rawlen); Serial.print(" want "); Serial.println( 2 * MITSUBISHI_BITS + 2);
30 | long data = 0;
31 | if (irparams.rawlen < 2 * MITSUBISHI_BITS + 2) return false ;
32 | int offset = 0; // Skip first space
33 | // Initial space
34 |
35 | #if 0
36 | // Put this back in for debugging - note can't use #DEBUG as if Debug on we don't see the repeat cos of the delay
37 | Serial.print("IR Gap: ");
38 | Serial.println( results->rawbuf[offset]);
39 | Serial.println( "test against:");
40 | Serial.println(results->rawbuf[offset]);
41 | #endif
42 |
43 | #if 0
44 | // Not seeing double keys from Mitsubishi
45 | if (results->rawbuf[offset] < MITSUBISHI_DOUBLE_SPACE_USECS) {
46 | // Serial.print("IR Gap found: ");
47 | results->bits = 0;
48 | results->value = REPEAT;
49 | results->decode_type = MITSUBISHI;
50 | return true;
51 | }
52 | #endif
53 |
54 | offset++;
55 |
56 | // Typical
57 | // 14200 7 41 7 42 7 42 7 17 7 17 7 18 7 41 7 18 7 17 7 17 7 18 7 41 8 17 7 17 7 18 7 17 7
58 |
59 | // Initial Space
60 | if (!MATCH_MARK(results->rawbuf[offset], MITSUBISHI_HDR_SPACE)) return false ;
61 | offset++;
62 |
63 | while (offset + 1 < irparams.rawlen) {
64 | if (MATCH_MARK(results->rawbuf[offset], MITSUBISHI_ONE_MARK)) data = (data << 1) | 1 ;
65 | else if (MATCH_MARK(results->rawbuf[offset], MITSUBISHI_ZERO_MARK)) data <<= 1 ;
66 | else return false ;
67 | offset++;
68 |
69 | if (!MATCH_SPACE(results->rawbuf[offset], MITSUBISHI_HDR_SPACE)) break ;
70 | offset++;
71 | }
72 |
73 | // Success
74 | results->bits = (offset - 1) / 2;
75 | if (results->bits < MITSUBISHI_BITS) {
76 | results->bits = 0;
77 | return false;
78 | }
79 |
80 | results->value = data;
81 | results->decode_type = MITSUBISHI;
82 | return true;
83 | }
84 | #endif
85 |
86 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/ir_NEC.cpp:
--------------------------------------------------------------------------------
1 | #include "IRremote.h"
2 | #include "IRremoteInt.h"
3 |
4 | //==============================================================================
5 | // N N EEEEE CCCC
6 | // NN N E C
7 | // N N N EEE C
8 | // N NN E C
9 | // N N EEEEE CCCC
10 | //==============================================================================
11 |
12 | #define NEC_BITS 32
13 | #define NEC_HDR_MARK 9000
14 | #define NEC_HDR_SPACE 4500
15 | #define NEC_BIT_MARK 560
16 | #define NEC_ONE_SPACE 1690
17 | #define NEC_ZERO_SPACE 560
18 | #define NEC_RPT_SPACE 2250
19 |
20 | //+=============================================================================
21 | #if SEND_NEC
22 | void IRsend::sendNEC (unsigned long data, int nbits)
23 | {
24 | // Set IR carrier frequency
25 | enableIROut(38);
26 |
27 | // Header
28 | mark(NEC_HDR_MARK);
29 | space(NEC_HDR_SPACE);
30 |
31 | // Data
32 | for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) {
33 | if (data & mask) {
34 | mark(NEC_BIT_MARK);
35 | space(NEC_ONE_SPACE);
36 | } else {
37 | mark(NEC_BIT_MARK);
38 | space(NEC_ZERO_SPACE);
39 | }
40 | }
41 |
42 | // Footer
43 | mark(NEC_BIT_MARK);
44 | space(0); // Always end with the LED off
45 | }
46 | #endif
47 |
48 | //+=============================================================================
49 | // NECs have a repeat only 4 items long
50 | //
51 | #if DECODE_NEC
52 | bool IRrecv::decodeNEC (decode_results *results)
53 | {
54 | long data = 0; // We decode in to here; Start with nothing
55 | int offset = 1; // Index in to results; Skip first entry!?
56 |
57 | // Check header "mark"
58 | if (!MATCH_MARK(results->rawbuf[offset], NEC_HDR_MARK)) return false ;
59 | offset++;
60 |
61 | // Check for repeat
62 | if ( (irparams.rawlen == 4)
63 | && MATCH_SPACE(results->rawbuf[offset ], NEC_RPT_SPACE)
64 | && MATCH_MARK (results->rawbuf[offset+1], NEC_BIT_MARK )
65 | ) {
66 | results->bits = 0;
67 | results->value = REPEAT;
68 | results->decode_type = NEC;
69 | return true;
70 | }
71 |
72 | // Check we have enough data
73 | if (irparams.rawlen < (2 * NEC_BITS) + 4) return false ;
74 |
75 | // Check header "space"
76 | if (!MATCH_SPACE(results->rawbuf[offset], NEC_HDR_SPACE)) return false ;
77 | offset++;
78 |
79 | // Build the data
80 | for (int i = 0; i < NEC_BITS; i++) {
81 | // Check data "mark"
82 | if (!MATCH_MARK(results->rawbuf[offset], NEC_BIT_MARK)) return false ;
83 | offset++;
84 | // Suppend this bit
85 | if (MATCH_SPACE(results->rawbuf[offset], NEC_ONE_SPACE )) data = (data << 1) | 1 ;
86 | else if (MATCH_SPACE(results->rawbuf[offset], NEC_ZERO_SPACE)) data = (data << 1) | 0 ;
87 | else return false ;
88 | offset++;
89 | }
90 |
91 | // Success
92 | results->bits = NEC_BITS;
93 | results->value = data;
94 | results->decode_type = NEC;
95 |
96 | return true;
97 | }
98 | #endif
99 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/ir_Panasonic.cpp:
--------------------------------------------------------------------------------
1 | #include "IRremote.h"
2 | #include "IRremoteInt.h"
3 |
4 | //==============================================================================
5 | // PPPP AAA N N AAA SSSS OOO N N IIIII CCCC
6 | // P P A A NN N A A S O O NN N I C
7 | // PPPP AAAAA N N N AAAAA SSS O O N N N I C
8 | // P A A N NN A A S O O N NN I C
9 | // P A A N N A A SSSS OOO N N IIIII CCCC
10 | //==============================================================================
11 |
12 | #define PANASONIC_BITS 48
13 | #define PANASONIC_HDR_MARK 3502
14 | #define PANASONIC_HDR_SPACE 1750
15 | #define PANASONIC_BIT_MARK 502
16 | #define PANASONIC_ONE_SPACE 1244
17 | #define PANASONIC_ZERO_SPACE 400
18 |
19 | //+=============================================================================
20 | #if SEND_PANASONIC
21 | void IRsend::sendPanasonic (unsigned int address, unsigned long data)
22 | {
23 | // Set IR carrier frequency
24 | enableIROut(35);
25 |
26 | // Header
27 | mark(PANASONIC_HDR_MARK);
28 | space(PANASONIC_HDR_SPACE);
29 |
30 | // Address
31 | for (unsigned long mask = 1UL << (16 - 1); mask; mask >>= 1) {
32 | mark(PANASONIC_BIT_MARK);
33 | if (address & mask) space(PANASONIC_ONE_SPACE) ;
34 | else space(PANASONIC_ZERO_SPACE) ;
35 | }
36 |
37 | // Data
38 | for (unsigned long mask = 1UL << (32 - 1); mask; mask >>= 1) {
39 | mark(PANASONIC_BIT_MARK);
40 | if (data & mask) space(PANASONIC_ONE_SPACE) ;
41 | else space(PANASONIC_ZERO_SPACE) ;
42 | }
43 |
44 | // Footer
45 | mark(PANASONIC_BIT_MARK);
46 | space(0); // Always end with the LED off
47 | }
48 | #endif
49 |
50 | //+=============================================================================
51 | #if DECODE_PANASONIC
52 | bool IRrecv::decodePanasonic (decode_results *results)
53 | {
54 | unsigned long long data = 0;
55 | int offset = 1;
56 |
57 | if (!MATCH_MARK(results->rawbuf[offset++], PANASONIC_HDR_MARK )) return false ;
58 | if (!MATCH_MARK(results->rawbuf[offset++], PANASONIC_HDR_SPACE)) return false ;
59 |
60 | // decode address
61 | for (int i = 0; i < PANASONIC_BITS; i++) {
62 | if (!MATCH_MARK(results->rawbuf[offset++], PANASONIC_BIT_MARK)) return false ;
63 |
64 | if (MATCH_SPACE(results->rawbuf[offset],PANASONIC_ONE_SPACE )) data = (data << 1) | 1 ;
65 | else if (MATCH_SPACE(results->rawbuf[offset],PANASONIC_ZERO_SPACE)) data = (data << 1) | 0 ;
66 | else return false ;
67 | offset++;
68 | }
69 |
70 | results->value = (unsigned long)data;
71 | results->address = (unsigned int)(data >> 32);
72 | results->decode_type = PANASONIC;
73 | results->bits = PANASONIC_BITS;
74 |
75 | return true;
76 | }
77 | #endif
78 |
79 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/ir_Samsung.cpp:
--------------------------------------------------------------------------------
1 | #include "IRremote.h"
2 | #include "IRremoteInt.h"
3 |
4 | //==============================================================================
5 | // SSSS AAA MMM SSSS U U N N GGGG
6 | // S A A M M M S U U NN N G
7 | // SSS AAAAA M M M SSS U U N N N G GG
8 | // S A A M M S U U N NN G G
9 | // SSSS A A M M SSSS UUU N N GGG
10 | //==============================================================================
11 |
12 | #define SAMSUNG_BITS 32
13 | #define SAMSUNG_HDR_MARK 5000
14 | #define SAMSUNG_HDR_SPACE 5000
15 | #define SAMSUNG_BIT_MARK 560
16 | #define SAMSUNG_ONE_SPACE 1600
17 | #define SAMSUNG_ZERO_SPACE 560
18 | #define SAMSUNG_RPT_SPACE 2250
19 |
20 | //+=============================================================================
21 | #if SEND_SAMSUNG
22 | void IRsend::sendSAMSUNG (unsigned long data, int nbits)
23 | {
24 | // Set IR carrier frequency
25 | enableIROut(38);
26 |
27 | // Header
28 | mark(SAMSUNG_HDR_MARK);
29 | space(SAMSUNG_HDR_SPACE);
30 |
31 | // Data
32 | for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) {
33 | if (data & mask) {
34 | mark(SAMSUNG_BIT_MARK);
35 | space(SAMSUNG_ONE_SPACE);
36 | } else {
37 | mark(SAMSUNG_BIT_MARK);
38 | space(SAMSUNG_ZERO_SPACE);
39 | }
40 | }
41 |
42 | // Footer
43 | mark(SAMSUNG_BIT_MARK);
44 | space(0); // Always end with the LED off
45 | }
46 | #endif
47 |
48 | //+=============================================================================
49 | // SAMSUNGs have a repeat only 4 items long
50 | //
51 | #if DECODE_SAMSUNG
52 | bool IRrecv::decodeSAMSUNG (decode_results *results)
53 | {
54 | long data = 0;
55 | int offset = 1; // Skip first space
56 |
57 | // Initial mark
58 | if (!MATCH_MARK(results->rawbuf[offset], SAMSUNG_HDR_MARK)) return false ;
59 | offset++;
60 |
61 | // Check for repeat
62 | if ( (irparams.rawlen == 4)
63 | && MATCH_SPACE(results->rawbuf[offset], SAMSUNG_RPT_SPACE)
64 | && MATCH_MARK(results->rawbuf[offset+1], SAMSUNG_BIT_MARK)
65 | ) {
66 | results->bits = 0;
67 | results->value = REPEAT;
68 | results->decode_type = SAMSUNG;
69 | return true;
70 | }
71 | if (irparams.rawlen < (2 * SAMSUNG_BITS) + 4) return false ;
72 |
73 | // Initial space
74 | if (!MATCH_SPACE(results->rawbuf[offset++], SAMSUNG_HDR_SPACE)) return false ;
75 |
76 | for (int i = 0; i < SAMSUNG_BITS; i++) {
77 | if (!MATCH_MARK(results->rawbuf[offset++], SAMSUNG_BIT_MARK)) return false ;
78 |
79 | if (MATCH_SPACE(results->rawbuf[offset], SAMSUNG_ONE_SPACE)) data = (data << 1) | 1 ;
80 | else if (MATCH_SPACE(results->rawbuf[offset], SAMSUNG_ZERO_SPACE)) data = (data << 1) | 0 ;
81 | else return false ;
82 | offset++;
83 | }
84 |
85 | // Success
86 | results->bits = SAMSUNG_BITS;
87 | results->value = data;
88 | results->decode_type = SAMSUNG;
89 | return true;
90 | }
91 | #endif
92 |
93 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/ir_Sanyo.cpp:
--------------------------------------------------------------------------------
1 | #include "IRremote.h"
2 | #include "IRremoteInt.h"
3 |
4 | //==============================================================================
5 | // SSSS AAA N N Y Y OOO
6 | // S A A NN N Y Y O O
7 | // SSS AAAAA N N N Y O O
8 | // S A A N NN Y O O
9 | // SSSS A A N N Y OOO
10 | //==============================================================================
11 |
12 | // I think this is a Sanyo decoder: Serial = SA 8650B
13 | // Looks like Sony except for timings, 48 chars of data and time/space different
14 |
15 | #define SANYO_BITS 12
16 | #define SANYO_HDR_MARK 3500 // seen range 3500
17 | #define SANYO_HDR_SPACE 950 // seen 950
18 | #define SANYO_ONE_MARK 2400 // seen 2400
19 | #define SANYO_ZERO_MARK 700 // seen 700
20 | #define SANYO_DOUBLE_SPACE_USECS 800 // usually ssee 713 - not using ticks as get number wrapround
21 | #define SANYO_RPT_LENGTH 45000
22 |
23 | //+=============================================================================
24 | #if DECODE_SANYO
25 | bool IRrecv::decodeSanyo (decode_results *results)
26 | {
27 | long data = 0;
28 | int offset = 0; // Skip first space <-- CHECK THIS!
29 |
30 | if (irparams.rawlen < (2 * SANYO_BITS) + 2) return false ;
31 |
32 | #if 0
33 | // Put this back in for debugging - note can't use #DEBUG as if Debug on we don't see the repeat cos of the delay
34 | Serial.print("IR Gap: ");
35 | Serial.println( results->rawbuf[offset]);
36 | Serial.println( "test against:");
37 | Serial.println(results->rawbuf[offset]);
38 | #endif
39 |
40 | // Initial space
41 | if (results->rawbuf[offset] < SANYO_DOUBLE_SPACE_USECS) {
42 | //Serial.print("IR Gap found: ");
43 | results->bits = 0;
44 | results->value = REPEAT;
45 | results->decode_type = SANYO;
46 | return true;
47 | }
48 | offset++;
49 |
50 | // Initial mark
51 | if (!MATCH_MARK(results->rawbuf[offset++], SANYO_HDR_MARK)) return false ;
52 |
53 | // Skip Second Mark
54 | if (!MATCH_MARK(results->rawbuf[offset++], SANYO_HDR_MARK)) return false ;
55 |
56 | while (offset + 1 < irparams.rawlen) {
57 | if (!MATCH_SPACE(results->rawbuf[offset++], SANYO_HDR_SPACE)) break ;
58 |
59 | if (MATCH_MARK(results->rawbuf[offset], SANYO_ONE_MARK)) data = (data << 1) | 1 ;
60 | else if (MATCH_MARK(results->rawbuf[offset], SANYO_ZERO_MARK)) data = (data << 1) | 0 ;
61 | else return false ;
62 | offset++;
63 | }
64 |
65 | // Success
66 | results->bits = (offset - 1) / 2;
67 | if (results->bits < 12) {
68 | results->bits = 0;
69 | return false;
70 | }
71 |
72 | results->value = data;
73 | results->decode_type = SANYO;
74 | return true;
75 | }
76 | #endif
77 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/ir_Sharp.cpp:
--------------------------------------------------------------------------------
1 | #include "IRremote.h"
2 | #include "IRremoteInt.h"
3 |
4 | //==============================================================================
5 | // SSSS H H AAA RRRR PPPP
6 | // S H H A A R R P P
7 | // SSS HHHHH AAAAA RRRR PPPP
8 | // S H H A A R R P
9 | // SSSS H H A A R R P
10 | //==============================================================================
11 |
12 | // Sharp and DISH support by Todd Treece: http://unionbridge.org/design/ircommand
13 | //
14 | // The send function has the necessary repeat built in because of the need to
15 | // invert the signal.
16 | //
17 | // Sharp protocol documentation:
18 | // http://www.sbprojects.com/knowledge/ir/sharp.htm
19 | //
20 | // Here is the LIRC file I found that seems to match the remote codes from the
21 | // oscilloscope:
22 | // Sharp LCD TV:
23 | // http://lirc.sourceforge.net/remotes/sharp/GA538WJSA
24 |
25 | #define SHARP_BITS 15
26 | #define SHARP_BIT_MARK 245
27 | #define SHARP_ONE_SPACE 1805
28 | #define SHARP_ZERO_SPACE 795
29 | #define SHARP_GAP 600000
30 | #define SHARP_RPT_SPACE 3000
31 |
32 | #define SHARP_TOGGLE_MASK 0x3FF
33 |
34 | //+=============================================================================
35 | #if SEND_SHARP
36 | void IRsend::sendSharpRaw (unsigned long data, int nbits)
37 | {
38 | enableIROut(38);
39 |
40 | // Sending codes in bursts of 3 (normal, inverted, normal) makes transmission
41 | // much more reliable. That's the exact behaviour of CD-S6470 remote control.
42 | for (int n = 0; n < 3; n++) {
43 | for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) {
44 | if (data & mask) {
45 | mark(SHARP_BIT_MARK);
46 | space(SHARP_ONE_SPACE);
47 | } else {
48 | mark(SHARP_BIT_MARK);
49 | space(SHARP_ZERO_SPACE);
50 | }
51 | }
52 |
53 | mark(SHARP_BIT_MARK);
54 | space(SHARP_ZERO_SPACE);
55 | delay(40);
56 |
57 | data = data ^ SHARP_TOGGLE_MASK;
58 | }
59 | }
60 | #endif
61 |
62 | //+=============================================================================
63 | // Sharp send compatible with data obtained through decodeSharp()
64 | // ^^^^^^^^^^^^^ FUNCTION MISSING!
65 | //
66 | #if SEND_SHARP
67 | void IRsend::sendSharp (unsigned int address, unsigned int command)
68 | {
69 | sendSharpRaw((address << 10) | (command << 2) | 2, SHARP_BITS);
70 | }
71 | #endif
72 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/ir_Sony.cpp:
--------------------------------------------------------------------------------
1 | #include "IRremote.h"
2 | #include "IRremoteInt.h"
3 |
4 | //==============================================================================
5 | // SSSS OOO N N Y Y
6 | // S O O NN N Y Y
7 | // SSS O O N N N Y
8 | // S O O N NN Y
9 | // SSSS OOO N N Y
10 | //==============================================================================
11 |
12 | #define SONY_BITS 12
13 | #define SONY_HDR_MARK 2400
14 | #define SONY_HDR_SPACE 600
15 | #define SONY_ONE_MARK 1200
16 | #define SONY_ZERO_MARK 600
17 | #define SONY_RPT_LENGTH 45000
18 | #define SONY_DOUBLE_SPACE_USECS 500 // usually ssee 713 - not using ticks as get number wrapround
19 |
20 | //+=============================================================================
21 | #if SEND_SONY
22 | void IRsend::sendSony (unsigned long data, int nbits)
23 | {
24 | // Set IR carrier frequency
25 | enableIROut(40);
26 |
27 | // Header
28 | mark(SONY_HDR_MARK);
29 | space(SONY_HDR_SPACE);
30 |
31 | // Data
32 | for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) {
33 | if (data & mask) {
34 | mark(SONY_ONE_MARK);
35 | space(SONY_HDR_SPACE);
36 | } else {
37 | mark(SONY_ZERO_MARK);
38 | space(SONY_HDR_SPACE);
39 | }
40 | }
41 |
42 | // We will have ended with LED off
43 | }
44 | #endif
45 |
46 | //+=============================================================================
47 | #if DECODE_SONY
48 | bool IRrecv::decodeSony (decode_results *results)
49 | {
50 | long data = 0;
51 | int offset = 0; // Dont skip first space, check its size
52 |
53 | if (irparams.rawlen < (2 * SONY_BITS) + 2) return false ;
54 |
55 | // Some Sony's deliver repeats fast after first
56 | // unfortunately can't spot difference from of repeat from two fast clicks
57 | if (results->rawbuf[offset] < SONY_DOUBLE_SPACE_USECS) {
58 | // Serial.print("IR Gap found: ");
59 | results->bits = 0;
60 | results->value = REPEAT;
61 |
62 | # ifdef DECODE_SANYO
63 | results->decode_type = SANYO;
64 | # else
65 | results->decode_type = UNKNOWN;
66 | # endif
67 |
68 | return true;
69 | }
70 | offset++;
71 |
72 | // Initial mark
73 | if (!MATCH_MARK(results->rawbuf[offset++], SONY_HDR_MARK)) return false ;
74 |
75 | while (offset + 1 < irparams.rawlen) {
76 | if (!MATCH_SPACE(results->rawbuf[offset++], SONY_HDR_SPACE)) break ;
77 |
78 | if (MATCH_MARK(results->rawbuf[offset], SONY_ONE_MARK)) data = (data << 1) | 1 ;
79 | else if (MATCH_MARK(results->rawbuf[offset], SONY_ZERO_MARK)) data = (data << 1) | 0 ;
80 | else return false ;
81 | offset++;
82 | }
83 |
84 | // Success
85 | results->bits = (offset - 1) / 2;
86 | if (results->bits < 12) {
87 | results->bits = 0;
88 | return false;
89 | }
90 | results->value = data;
91 | results->decode_type = SONY;
92 | return true;
93 | }
94 | #endif
95 |
96 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/ir_Whynter.cpp:
--------------------------------------------------------------------------------
1 | #include "IRremote.h"
2 | #include "IRremoteInt.h"
3 |
4 | //==============================================================================
5 | // W W H H Y Y N N TTTTT EEEEE RRRRR
6 | // W W H H Y Y NN N T E R R
7 | // W W W HHHHH Y N N N T EEE RRRR
8 | // W W W H H Y N NN T E R R
9 | // WWW H H Y N N T EEEEE R R
10 | //==============================================================================
11 |
12 | #define WHYNTER_BITS 32
13 | #define WHYNTER_HDR_MARK 2850
14 | #define WHYNTER_HDR_SPACE 2850
15 | #define WHYNTER_BIT_MARK 750
16 | #define WHYNTER_ONE_MARK 750
17 | #define WHYNTER_ONE_SPACE 2150
18 | #define WHYNTER_ZERO_MARK 750
19 | #define WHYNTER_ZERO_SPACE 750
20 |
21 | //+=============================================================================
22 | #if SEND_WHYNTER
23 | void IRsend::sendWhynter (unsigned long data, int nbits)
24 | {
25 | // Set IR carrier frequency
26 | enableIROut(38);
27 |
28 | // Start
29 | mark(WHYNTER_ZERO_MARK);
30 | space(WHYNTER_ZERO_SPACE);
31 |
32 | // Header
33 | mark(WHYNTER_HDR_MARK);
34 | space(WHYNTER_HDR_SPACE);
35 |
36 | // Data
37 | for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) {
38 | if (data & mask) {
39 | mark(WHYNTER_ONE_MARK);
40 | space(WHYNTER_ONE_SPACE);
41 | } else {
42 | mark(WHYNTER_ZERO_MARK);
43 | space(WHYNTER_ZERO_SPACE);
44 | }
45 | }
46 |
47 | // Footer
48 | mark(WHYNTER_ZERO_MARK);
49 | space(WHYNTER_ZERO_SPACE); // Always end with the LED off
50 | }
51 | #endif
52 |
53 | //+=============================================================================
54 | #if DECODE_WHYNTER
55 | bool IRrecv::decodeWhynter (decode_results *results)
56 | {
57 | long data = 0;
58 | int offset = 1; // skip initial space
59 |
60 | // Check we have the right amount of data
61 | if (irparams.rawlen < (2 * WHYNTER_BITS) + 6) return false ;
62 |
63 | // Sequence begins with a bit mark and a zero space
64 | if (!MATCH_MARK (results->rawbuf[offset++], WHYNTER_BIT_MARK )) return false ;
65 | if (!MATCH_SPACE(results->rawbuf[offset++], WHYNTER_ZERO_SPACE)) return false ;
66 |
67 | // header mark and space
68 | if (!MATCH_MARK (results->rawbuf[offset++], WHYNTER_HDR_MARK )) return false ;
69 | if (!MATCH_SPACE(results->rawbuf[offset++], WHYNTER_HDR_SPACE)) return false ;
70 |
71 | // data bits
72 | for (int i = 0; i < WHYNTER_BITS; i++) {
73 | if (!MATCH_MARK(results->rawbuf[offset++], WHYNTER_BIT_MARK)) return false ;
74 |
75 | if (MATCH_SPACE(results->rawbuf[offset], WHYNTER_ONE_SPACE )) data = (data << 1) | 1 ;
76 | else if (MATCH_SPACE(results->rawbuf[offset], WHYNTER_ZERO_SPACE)) data = (data << 1) | 0 ;
77 | else return false ;
78 | offset++;
79 | }
80 |
81 | // trailing mark
82 | if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) return false ;
83 |
84 | // Success
85 | results->bits = WHYNTER_BITS;
86 | results->value = data;
87 | results->decode_type = WHYNTER;
88 | return true;
89 | }
90 | #endif
91 |
92 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/keywords.txt:
--------------------------------------------------------------------------------
1 | #######################################
2 | # Syntax Coloring Map For IRremote
3 | #######################################
4 |
5 | #######################################
6 | # Datatypes (KEYWORD1)
7 | #######################################
8 |
9 | decode_results KEYWORD1
10 | IRrecv KEYWORD1
11 | IRsend KEYWORD1
12 |
13 | #######################################
14 | # Methods and Functions (KEYWORD2)
15 | #######################################
16 |
17 | blink13 KEYWORD2
18 | decode KEYWORD2
19 | enableIRIn KEYWORD2
20 | resume KEYWORD2
21 | enableIROut KEYWORD2
22 | sendNEC KEYWORD2
23 | sendSony KEYWORD2
24 | sendSanyo KEYWORD2
25 | sendMitsubishi KEYWORD2
26 | sendRaw KEYWORD2
27 | sendRC5 KEYWORD2
28 | sendRC6 KEYWORD2
29 | sendDISH KEYWORD2
30 | sendSharp KEYWORD2
31 | sendSharpRaw KEYWORD2
32 | sendPanasonic KEYWORD2
33 | sendJVC KEYWORD2
34 |
35 | #######################################
36 | # Constants (LITERAL1)
37 | #######################################
38 |
39 | NEC LITERAL1
40 | SONY LITERAL1
41 | SANYO LITERAL1
42 | MITSUBISHI LITERAL1
43 | RC5 LITERAL1
44 | RC6 LITERAL1
45 | DISH LITERAL1
46 | SHARP LITERAL1
47 | PANASONIC LITERAL1
48 | JVC LITERAL1
49 | LG LITERAL1
50 | AIWA_RC_T501 LITERAL1
51 | UNKNOWN LITERAL1
52 | REPEAT LITERAL1
53 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/library.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "IRremote",
3 | "keywords": "infrared, ir, remote",
4 | "description": "Send and receive infrared signals with multiple protocols",
5 | "repository":
6 | {
7 | "type": "git",
8 | "url": "https://github.com/shirriff/Arduino-IRremote.git"
9 | },
10 | "frameworks": "arduino",
11 | "platforms": "atmelavr"
12 | }
13 |
--------------------------------------------------------------------------------
/libraries/Arduino-IRremote/library.properties:
--------------------------------------------------------------------------------
1 | name=IRremote
2 | version=2.0.1
3 | author=shirriff
4 | maintainer=shirriff
5 | sentence=Send and receive infrared signals with multiple protocols
6 | paragraph=Send and receive infrared signals with multiple protocols
7 | category=Signal Input/Output
8 | url=https://github.com/shirriff/Arduino-IRremote.git
9 | architectures=*
10 |
--------------------------------------------------------------------------------
/libraries/BatReader/BatReader.cpp:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Zowi Battery Reader Library
3 | *
4 | * @version 20150831
5 | * @author Raul de Pablos Martin
6 | *
7 | ******************************************************************************/
8 |
9 | #include "BatReader.h"
10 |
11 | #if defined(ARDUINO) && ARDUINO >= 100
12 | #include "Arduino.h"
13 | #else
14 | #include "WProgram.h"
15 | #endif
16 |
17 | BatReader::BatReader() {
18 | }
19 |
20 | double BatReader::readBatVoltage(void) {
21 | double readed = (double)(analogRead(BAT_PIN)*ANA_REF)/1024;
22 | if(readed > BAT_MAX) return BAT_MAX;
23 | else return readed;
24 | }
25 |
26 | double BatReader::readBatPercent(void) {
27 | double value = (SLOPE*readBatVoltage()) - OFFSET;
28 | if(value < 0) return 0;
29 | else return value;
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/libraries/BatReader/BatReader.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Zowi Battery Reader Library
3 | *
4 | * @version 20150824
5 | * @author Raul de Pablos Martin
6 | *
7 | ******************************************************************************/
8 | #ifndef __BATREADER_H__
9 | #define __BATREADER_H__
10 |
11 | #if defined(ARDUINO) && ARDUINO >= 100
12 | #include "Arduino.h"
13 | #else
14 | #include "WProgram.h"
15 | #include "pins_arduino.h"
16 | #endif
17 |
18 | ////////////////////////////
19 | // Definitions //
20 | ////////////////////////////
21 | #define BAT_PIN A7
22 | #define BAT_MAX 4.2
23 | #define BAT_MIN 3.25
24 | #define ANA_REF 5
25 | #define SLOPE 100/(BAT_MAX - BAT_MIN)
26 | #define OFFSET (100*BAT_MIN)/(BAT_MAX - BAT_MIN)
27 |
28 | class BatReader
29 | {
30 | public:
31 | ////////////////////////////
32 | // Enumerations //
33 | ////////////////////////////
34 |
35 | ////////////////////////////
36 | // Variables //
37 | ////////////////////////////
38 |
39 | ////////////////////////////
40 | // Functions //
41 | ////////////////////////////
42 | // BatReader -- BatReader class constructor
43 | BatReader();
44 |
45 | // readBatPercent
46 | double readBatVoltage(void);
47 |
48 | // readBatPercent
49 | double readBatPercent(void);
50 |
51 |
52 |
53 | private:
54 | ////////////////////////////
55 | // Enumerations //
56 | ////////////////////////////
57 |
58 |
59 | ////////////////////////////
60 | // Variables //
61 | ////////////////////////////
62 |
63 |
64 | ////////////////////////////
65 | // Functions //
66 | ////////////////////////////
67 |
68 |
69 | };
70 |
71 | #endif // BATREADER_H //
72 |
--------------------------------------------------------------------------------
/libraries/BatReader/BatReader.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smartmecard/arduino-smart-robot-car/c5a0554a11c4e41a61c79af503f3163ffec319cb/libraries/BatReader/BatReader.zip
--------------------------------------------------------------------------------
/libraries/BatReader/BatReader_Example/BatReader_Example.ino:
--------------------------------------------------------------------------------
1 | #include "BatReader.h"
2 |
3 | BatReader batreader;
4 |
5 | void setup() {
6 | // put your setup code here, to run once:
7 | Serial.begin(115200);
8 |
9 | }
10 |
11 | void loop() {
12 | Serial.print("Battery Voltage: ");
13 | Serial.println(batreader.readBatVoltage());
14 | Serial.print("Battery Percentage: ");
15 | Serial.print(batreader.readBatPercent());
16 | Serial.println("%\n\r");
17 | delay(1000);
18 | }
19 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/EnableInterrupt.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smartmecard/arduino-smart-robot-car/c5a0554a11c4e41a61c79af503f3163ffec319cb/libraries/EnableInterrupt/EnableInterrupt.zip
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/examples/AllPins2560/Makefile:
--------------------------------------------------------------------------------
1 | # Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!)
2 | BOARD_TAG = 2560
3 | ARDUINO_PORT = /dev/ttyACM0
4 | ARDUINO_LIBS =
5 | AVR_TOOLS_DIR = /usr
6 |
7 | CFLAGS_STD = -g
8 | CXXFLAGS_STD = -g
9 |
10 | include /usr/share/arduino/Arduino.mk
11 |
12 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/examples/AllPins328/Makefile:
--------------------------------------------------------------------------------
1 | # Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!)
2 | BOARD_TAG = atmega328
3 | ARDUINO_PORT = /dev/ttyUSB0
4 | #BOARD_TAG = 2560
5 | #ARDUINO_PORT = /dev/ttyACM0
6 | ARDUINO_LIBS =
7 | AVR_TOOLS_DIR = /usr
8 |
9 | CFLAGS_STD = -g
10 | CXXFLAGS_STD = -g
11 |
12 | include /usr/share/arduino/Arduino.mk
13 |
14 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/examples/HiSpeed/HiSpeed.ino:
--------------------------------------------------------------------------------
1 | // EnableInterrupt HiSpeed example sketch
2 | // See https://github.com/GreyGnome/EnableInterrupt and the README.md for more information.
3 |
4 | // This example demonstrates the use of the EnableInterrupt library on a single pin of your choice.
5 | // It uses the "HiSpeed" mode of the library.
6 | // This has only been tested on an Arduino Duemilanove and Mega ADK.
7 | // It is designed to work with the Arduino Duemilanove/Uno, Arduino Mega2560/ADK, the Arduino
8 | // Leonardo, and the Arduino Due. Please let me know how you fare on the Leonardo or Due.
9 |
10 | // To use:
11 |
12 | // 1. You must be using a fairly recent version of the Arduino IDE software on your PC/Mac,
13 | // that is, version 1.0.1 or later. Check Help->About Arduino in the IDE.
14 |
15 | // 2. Wire a simple switch to any Analog or Digital pin (known as ARDUINOPIN, defined below)
16 | // that supports interrupts. See https://github.com/GreyGnome/EnableInterrupt/wiki/Usage#Summary
17 | // Attach the other end to a GND pin. A "single pole single throw momentary contact normally
18 | // open" // pushbutton switch is best for the most interrupting fun.
19 | // See https://www.sparkfun.com/products/97 and https://octopart.com/b3f-1000-omron-3117
20 |
21 | // 3. When pressed, the switch will connect the pin to ground ("low", or "0") voltage, and interrupt the
22 | // processor. See http://arduino.cc/en/Tutorial/DigitalPins
23 |
24 | // 4. The interrupt is serviced immediately, and the ISR (Interrupt SubRoutine) sets the value of a global
25 | // variable. Open Tools->Serial Monitor in the IDE to see the results of your interrupts.
26 |
27 | // 5. Peruse the Examples directory for more elaborate examples.
28 |
29 | // 6. Create your own sketch using the EnableInterrupt library!
30 |
31 | // Refer to
32 | // https://github.com/GreyGnome/EnableInterrupt/wiki/Usage#Summary
33 |
34 | #define NEEDFORSPEED
35 |
36 | #define INTERRUPT_FLAG_PIN8 myvariable_pin8 // NOTICE: NO semicolon!!!
37 |
38 | #include
39 |
40 | // Attach the interrupt in setup()
41 | void setup() {
42 | //uint8_t pind, pink;
43 | Serial.begin(115200);
44 | EI_printPSTR("---------------------------------------\r\n");
45 | pinMode(8, INPUT_PULLUP); // Configure the pin as an input, and turn on the pullup resistor.
46 | // See http://arduino.cc/en/Tutorial/DigitalPins
47 | enableInterruptFast(8, CHANGE);
48 | }
49 |
50 | // In the loop, we just check to see where the interrupt count is at. The value gets updated by the
51 | // interrupt routine.
52 | void loop() {
53 | EI_printPSTR("---------------------------------------\r\n");
54 | delay(1000); // Every second,
55 | if (myvariable_pin8) {
56 | EI_printPSTR("Pin 8 was interrupted: ");
57 | Serial.print(myvariable_pin8, DEC); // print the interrupt count.
58 | EI_printPSTR(" times so far.\r\n");
59 | myvariable_pin8=0;
60 | }
61 | else {
62 | EI_printPSTR("No interrupts.\r\n");
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/examples/HiSpeed/Makefile:
--------------------------------------------------------------------------------
1 | # Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!)
2 | BOARD_TAG = atmega328
3 | ARDUINO_PORT = /dev/ttyUSB0
4 | #BOARD_TAG = 2560
5 | #ARDUINO_PORT = /dev/ttyACM0
6 | ARDUINO_LIBS =
7 | AVR_TOOLS_DIR = /usr
8 |
9 | CFLAGS_STD = -g
10 | CXXFLAGS_STD = -g
11 |
12 | include /usr/share/arduino/Arduino.mk
13 |
14 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/examples/HiSpeed/README:
--------------------------------------------------------------------------------
1 | Note: This code has not been tested! Caveat Programmer. I will do it asap.
2 | (I have tested the HiSpeed code using the HiSpeedTest sketch, so I'm confident
3 | the library is working properly. Also this sketch compiles.).
4 | -GreyGnome
5 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/examples/HiSpeedAllPins2560/Makefile:
--------------------------------------------------------------------------------
1 | # Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!)
2 | BOARD_TAG = 2560
3 | ARDUINO_PORT = /dev/ttyACM0
4 | ARDUINO_LIBS =
5 | AVR_TOOLS_DIR = /usr
6 |
7 | CFLAGS_STD = -g
8 | CXXFLAGS_STD = -g
9 |
10 | include /usr/share/arduino/Arduino.mk
11 |
12 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/examples/HiSpeedAllPins328/HiSpeedAllPins328.ino:
--------------------------------------------------------------------------------
1 | // EnableInterrupt Simple example sketch
2 | // See the Wiki at http://code.google.com/p/arduino-pinchangeint/wiki for more information.
3 |
4 | // This example demonstrates the use of the EnableInterrupt library on all pins.
5 | // The library has only been tested on an Arduino Duemilanove and Mega ADK.
6 |
7 | #define NEEDFORSPEED
8 | #define INTERRUPT_FLAG_PIN2 iflag_pin2
9 | #define INTERRUPT_FLAG_PIN3 iflag_pin3
10 | #define INTERRUPT_FLAG_PIN4 iflag_pin4
11 | #define INTERRUPT_FLAG_PIN5 iflag_pin5
12 | #define INTERRUPT_FLAG_PIN6 iflag_pin6
13 | #define INTERRUPT_FLAG_PIN7 iflag_pin7
14 | #define INTERRUPT_FLAG_PIN8 iflag_pin8
15 | #define INTERRUPT_FLAG_PIN9 iflag_pin9
16 | #define INTERRUPT_FLAG_PIN10 iflag_pin10
17 | #define INTERRUPT_FLAG_PIN11 iflag_pin11
18 | #define INTERRUPT_FLAG_PIN12 iflag_pin12
19 | #define INTERRUPT_FLAG_PIN13 iflag_pin13
20 | #define INTERRUPT_FLAG_PINA0 iflag_pinA0
21 | #define INTERRUPT_FLAG_PINA1 iflag_pinA1
22 | #define INTERRUPT_FLAG_PINA2 iflag_pinA2
23 | #define INTERRUPT_FLAG_PINA3 iflag_pinA3
24 | #define INTERRUPT_FLAG_PINA4 iflag_pinA4
25 | #define INTERRUPT_FLAG_PINA5 iflag_pinA5
26 |
27 | #include
28 |
29 | volatile uint8_t anyInterruptCounter=0;
30 |
31 | #ifdef ARDUINO_328
32 | #define PINCOUNT(x) iflag_pin ##x
33 |
34 | #define updateOn(x) \
35 | if (PINCOUNT(x) != 0) { \
36 | printIt((char *) #x, PINCOUNT(x)); \
37 | PINCOUNT(x)=0; \
38 | }
39 |
40 | #define disablePCInterrupt(x) \
41 | disableInterrupt( x | PINCHANGEINTERRUPT)
42 |
43 | #define setupPCInterrupt(x) \
44 | EI_printPSTR("Add PinChange pin: "); \
45 | EI_printPSTR(#x); \
46 | EI_printPSTR("\r\n"); \
47 | pinMode( x, INPUT_PULLUP); \
48 | enableInterruptFast( x | PINCHANGEINTERRUPT, CHANGE)
49 |
50 | #define setupInterrupt(x) \
51 | EI_printPSTR("Add pin: "); \
52 | EI_printPSTR(#x); \
53 | EI_printPSTR("\r\n"); \
54 | pinMode( x, INPUT_PULLUP); \
55 | enableInterruptFast( x, CHANGE)
56 |
57 | #define setupExInterrupt(x) \
58 | EI_printPSTR("Add External pin: "); \
59 | EI_printPSTR(#x); \
60 | EI_printPSTR("\r\n"); \
61 | pinMode( x, INPUT_PULLUP); \
62 | enableInterruptFast( x , CHANGE)
63 |
64 | #else
65 | #error This sketch supports 328-based Arduinos only.
66 | #endif
67 |
68 | void printIt(char *pinNumber, uint8_t count) {
69 | EI_printPSTR(" Pin ");
70 | Serial.print(pinNumber);
71 | EI_printPSTR(" was interrupted: ");
72 | Serial.println(count, DEC);
73 | }
74 |
75 | // Attach the interrupt in setup()
76 | // NOTE: PORTJ2-6 (aka, "Pin '70', '71', '72', '73', '74'" are turned on as OUTPUT.
77 | // These are not true pins on the Arduino Mega series!
78 | void setup() {
79 | Serial.begin(115200);
80 | EI_printPSTR("--- START ------------------------------------\r\n");
81 | #ifdef DEBUG
82 | pinMode(PINSIGNAL, OUTPUT);
83 | #endif
84 | // PINS 0 and 1 NOT USED BECAUSE OF Serial.print()
85 | setupPCInterrupt(2); // by default, would be External Interrupt
86 | setupExInterrupt(3);
87 | setupInterrupt(4);
88 | setupInterrupt(5);
89 | setupInterrupt(6);
90 | setupInterrupt(7);
91 | setupInterrupt(8);
92 | setupInterrupt(9);
93 | setupInterrupt(10);
94 | setupInterrupt(11);
95 | setupInterrupt(12);
96 | #ifndef DEBUG
97 | // NOTE: Because the Arduino Duemilanove has an LED to ground and a 1k resistor in series with
98 | // it to the pin, Voltage at the pin should be hovering between 1-3 volts. 'nearly' ground. So
99 | // a wire to ground will not trip an interrupt, even though we have INPUT_PULLUP. A wire to PWR
100 | // will trigger an interrupt. The Uno has a op-amp buffer/driver to the LED, so will not have
101 | // this problem; it will behave like the other pins.
102 | setupInterrupt(13);
103 | #endif
104 | setupInterrupt(A0);
105 | setupInterrupt(A1);
106 | setupInterrupt(A2);
107 | setupInterrupt(A3);
108 | setupInterrupt(A4);
109 | setupInterrupt(A5);
110 | }
111 |
112 | uint8_t externalFlag=1;
113 | uint8_t enabledToggle=1;
114 | uint8_t disableCounter=0;
115 | // In the loop, we just check to see where the interrupt count is at. The value gets updated by
116 | // the interrupt routine.
117 | void loop() {
118 | EI_printPSTR("------\r\n");
119 | delay(1000); // Perform the loop every second.
120 | if (disableCounter & 0x08) {
121 | EI_printPSTR("Toggle 2, 3, 4, 8, A0...");
122 | delay(1000);
123 | if (enabledToggle==1) {
124 | EI_printPSTR(" off\r\n");
125 | disablePCInterrupt(2);
126 | if (externalFlag == 1) {
127 | EI_printPSTR("Disable pin 3 external interrupt\r\n");
128 | disableInterrupt(3);
129 | }
130 | else {
131 | EI_printPSTR("Disable pin 3 pin change interrupt\r\n");
132 | disablePCInterrupt(3);
133 | }
134 | disableInterrupt(4);
135 | disableInterrupt(8);
136 | disableInterrupt(A0);
137 | enabledToggle=0;
138 | }
139 | else {
140 | if (externalFlag == 1) {
141 | EI_printPSTR("3 is now a Pin Change Interrupt.\r\n");
142 | setupPCInterrupt(3); // make sure we can switch functions.
143 | externalFlag=0;
144 | } else {
145 | EI_printPSTR("3 is now an External Interrupt.\r\n");
146 | setupExInterrupt(3);
147 | externalFlag=1;
148 | }
149 | setupPCInterrupt(2);
150 | setupInterrupt(4);
151 | setupInterrupt(8);
152 | setupInterrupt(A0);
153 | enabledToggle=1;
154 | }
155 | disableCounter=0;
156 | }
157 | updateOn(2);
158 | updateOn(3);
159 | updateOn(4);
160 | updateOn(5);
161 | updateOn(6);
162 | updateOn(7);
163 | updateOn(8);
164 | updateOn(9);
165 | updateOn(10);
166 | updateOn(11);
167 | updateOn(12);
168 | updateOn(13);
169 | updateOn(A0);
170 | updateOn(A1);
171 | updateOn(A2);
172 | updateOn(A3);
173 | updateOn(A4);
174 | updateOn(A5);
175 | disableCounter++;
176 | }
177 |
178 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/examples/HiSpeedAllPins328/Makefile:
--------------------------------------------------------------------------------
1 | # Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!)
2 | BOARD_TAG = atmega328
3 | ARDUINO_PORT = /dev/ttyUSB0
4 | #BOARD_TAG = 2560
5 | #ARDUINO_PORT = /dev/ttyACM0
6 | ARDUINO_LIBS =
7 | AVR_TOOLS_DIR = /usr
8 |
9 | CFLAGS_STD = -g
10 | CXXFLAGS_STD = -g
11 |
12 | include /usr/share/arduino/Arduino.mk
13 |
14 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/examples/HiSpeedTest/HiSpeedTest.ino:
--------------------------------------------------------------------------------
1 | // EnableInterrupt Simple example sketch
2 | // See https://github.com/GreyGnome/EnableInterrupt and the README.md for more information.
3 | //
4 | // https://github.com/GreyGnome/EnableInterrupt/wiki/Usage#Summary
5 |
6 | //#define OLDLIBRARY
7 |
8 | #define NEEDFORSPEED
9 |
10 | #define THEINTERRUPTPIN8
11 | // Define the above, and undefine this for External Interrupt measurements.
12 | //#define THEINTERRUPTPIN2
13 |
14 | #if defined THEINTERRUPTPIN8
15 | #define PININTERRUPT 8
16 | #define PININTERRUPT_ON PORTB |= (1 << PB0)
17 | #define PININTERRUPT_OFF PORTB &= ~(1 << PB0)
18 | #define THEINTERRUPTVARIABLE myvariable_pin8
19 | #ifdef NEEDFORSPEED
20 | #define INTERRUPT_FLAG_PIN8 myvariable_pin8 // NOTICE: NO semicolon!!! This needs to track the PININTERRUPT pin
21 | #else
22 | volatile uint8_t myvariable_pin8=0;
23 | #endif
24 | #endif
25 |
26 | #if defined THEINTERRUPTPIN2
27 | #define PININTERRUPT 2
28 | #define PININTERRUPT_ON PORTD |= (1 << PD2)
29 | #define PININTERRUPT_OFF PORTD &= ~(1 << PD2)
30 | #define THEINTERRUPTVARIABLE myvariable_pin2
31 | #ifdef NEEDFORSPEED
32 | #define INTERRUPT_FLAG_PIN2 myvariable_pin2 // NOTICE: NO semicolon!!! This needs to track the PININTERRUPT pin
33 | #else
34 | volatile uint8_t myvariable_pin2=0;
35 | #endif
36 | #endif
37 |
38 |
39 | #ifdef OLDLIBRARY
40 | #include
41 | #define EI_printPSTR(x) SerialPrint_P(PSTR(x))
42 | void SerialPrint_P(const char *str) {
43 | for (uint8_t c; (c = pgm_read_byte(str)); str++) Serial.write(c);
44 | }
45 | #else
46 | #include
47 | #endif
48 | #include
49 |
50 | void incrementMyVariable() { // The compiler is smart: only uses memory if needed (ie, NEEDFORSPEED not defined)
51 | THEINTERRUPTVARIABLE++;
52 | }
53 |
54 | // Attach the interrupt in setup()
55 | void setup() {
56 | //uint8_t pind, pink;
57 | Serial.begin(115200);
58 | EI_printPSTR("---------------------------------------\r\n");
59 | pinMode(PININTERRUPT, OUTPUT); // Configure the pin as an output
60 | PININTERRUPT_OFF;
61 | #ifdef OLDLIBRARY
62 | attachPinChangeInterrupt(PININTERRUPT, incrementMyVariable, CHANGE);
63 | #else
64 | #ifdef NEEDFORSPEED
65 | enableInterruptFast(PININTERRUPT, CHANGE);
66 | #else
67 | enableInterrupt(PININTERRUPT, incrementMyVariable, CHANGE);
68 | #endif
69 | #endif
70 | EI_printPSTR("Interrupt enabled, let's go!");
71 | }
72 |
73 | // In the loop, we just check to see where the interrupt count is at. The value gets updated by the
74 | // interrupt routine.
75 | void loop() {
76 |
77 | EI_printPSTR("---------------------------------------\r\n");
78 | delay(1000); // Every second,
79 | PININTERRUPT_ON; // software interrupt
80 | _NOP(); // See "8-bit AVR Microcontroller with 4/8/16/32K Bytes In-System Programmable
81 | _NOP(); // Flash" document, Rev. 8271C-AVR-08/10, p. 71.
82 | _NOP(); // The interrupt signal must be held until PCIFR is changed, in order for the
83 | #if defined THEINTERRUPTPIN8
84 | _NOP(); // CPU to execute the ISR. This requires 4 nop assembler instructions.
85 | #else
86 | // (three nop's for an External Interrupt)
87 | #endif
88 | PININTERRUPT_OFF; // ...This is after the interrupt.
89 | if (THEINTERRUPTVARIABLE > 0) {
90 | EI_printPSTR("Pin was interrupted: ");
91 | Serial.print(THEINTERRUPTVARIABLE, DEC); // print the interrupt count.
92 | EI_printPSTR(" times so far.\r\n");
93 | THEINTERRUPTVARIABLE=0;
94 | }
95 | else {
96 | EI_printPSTR("No interrupts.\r\n");
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/examples/HiSpeedTest/Makefile:
--------------------------------------------------------------------------------
1 | # Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!)
2 | BOARD_TAG = atmega328
3 | ARDUINO_PORT = /dev/ttyUSB0
4 | #BOARD_TAG = 2560
5 | #ARDUINO_PORT = /dev/ttyACM0
6 | ARDUINO_LIBS =
7 | AVR_TOOLS_DIR = /usr
8 |
9 | CFLAGS_STD = -g
10 | CXXFLAGS_STD = -g
11 |
12 | include /usr/share/arduino/Arduino.mk
13 |
14 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/examples/InterruptedPin2560/Makefile:
--------------------------------------------------------------------------------
1 | # Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!)
2 | #BOARD_TAG = atmega328
3 | #ARDUINO_PORT = /dev/ttyUSB0
4 | BOARD_TAG = 2560
5 | ARDUINO_PORT = /dev/ttyACM0
6 | ARDUINO_LIBS =
7 | AVR_TOOLS_DIR = /usr
8 |
9 | CFLAGS_STD = -g
10 | CXXFLAGS_STD = -g
11 |
12 | include /usr/share/arduino/Arduino.mk
13 |
14 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/examples/InterruptedPin328/InterruptedPin328.ino:
--------------------------------------------------------------------------------
1 | // EnableInterrupt example sketch
2 | // See the Wiki at http://code.google.com/p/arduino-pinchangeint/wiki for more information.
3 |
4 | // This example demonstrates the use of the EnableInterrupt library on all pins.
5 | // It tests the EI_ARDUINO_INTERRUPTED_PIN facility.
6 | // The library has only been tested on an Arduino Duemilanove and Mega ADK.
7 |
8 | #define EI_ARDUINO_INTERRUPTED_PIN
9 | #include
10 |
11 | volatile uint8_t externalInterruptFlag=0;
12 | volatile uint8_t pinChangeInterruptFlag=0;
13 |
14 | #ifdef ARDUINO_328
15 | #define PINCOUNT(x) pin ##x ##Count
16 |
17 | void interruptFunction () {
18 | pinChangeInterruptFlag=arduinoInterruptedPin;
19 | }
20 |
21 | void interruptExFunction () {
22 | externalInterruptFlag=arduinoInterruptedPin;
23 | }
24 |
25 | #define disablePCInterrupt(x) \
26 | disableInterrupt( x | PINCHANGEINTERRUPT)
27 |
28 | #define setupPCInterrupt(x) \
29 | EI_printPSTR("Add PinChange pin: "); \
30 | EI_printPSTR(#x); \
31 | EI_printPSTR("\r\n"); \
32 | pinMode( x, INPUT_PULLUP); \
33 | enableInterrupt( x | PINCHANGEINTERRUPT, interruptFunction, CHANGE)
34 |
35 | #define setupInterrupt(x) \
36 | EI_printPSTR("Add pin: "); \
37 | EI_printPSTR(#x); \
38 | EI_printPSTR("\r\n"); \
39 | pinMode( x, INPUT_PULLUP); \
40 | enableInterrupt( x, interruptFunction, CHANGE)
41 |
42 | #define setupExInterrupt(x) \
43 | EI_printPSTR("Add External pin: "); \
44 | EI_printPSTR(#x); \
45 | EI_printPSTR("\r\n"); \
46 | pinMode( x, INPUT_PULLUP); \
47 | enableInterrupt( x , interruptExFunction, CHANGE)
48 | #else
49 | #error This sketch supports 328-based Arduinos only.
50 | #endif
51 |
52 | void printIt(char *pinNumber, uint8_t count) {
53 | EI_printPSTR(" Pin ");
54 | Serial.print(pinNumber);
55 | EI_printPSTR(" was interrupted: ");
56 | Serial.println(count, DEC);
57 | }
58 |
59 | // Attach the interrupt in setup()
60 | // NOTE: PORTJ2-6 (aka, "Pin '70', '71', '72', '73', '74'" are turned on as OUTPUT.
61 | // These are not true pins on the Arduino Mega series!
62 | void setup() {
63 | Serial.begin(115200);
64 | EI_printPSTR("--- START ------------------------------------\r\n");
65 | #ifdef DEBUG
66 | pinMode(PINSIGNAL, OUTPUT);
67 | #endif
68 | // PINS 0 and 1 NOT USED BECAUSE OF Serial.print()
69 | setupPCInterrupt(2); // by default, would be External Interrupt
70 | setupExInterrupt(3);
71 | setupInterrupt(4);
72 | setupInterrupt(5);
73 | setupInterrupt(6);
74 | setupInterrupt(7);
75 | setupInterrupt(8);
76 | setupInterrupt(9);
77 | setupInterrupt(10);
78 | setupInterrupt(11);
79 | setupInterrupt(12);
80 | #ifndef DEBUG
81 | // NOTE: Because the Arduino Duemilanove has an LED to ground and a 1k resistor in series with
82 | // it to the pin, Voltage at the pin should be hovering between 1-3 volts. 'nearly' ground. So
83 | // a wire to ground will not trip an interrupt, even though we have INPUT_PULLUP. A wire to PWR
84 | // will trigger an interrupt. The Uno has an op-amp buffer/driver to the LED, so will not have
85 | // this problem; it will behave like the other pins.
86 | setupInterrupt(13);
87 | #endif
88 | setupInterrupt(A0);
89 | setupInterrupt(A1);
90 | setupInterrupt(A2);
91 | setupInterrupt(A3);
92 | setupInterrupt(A4);
93 | setupInterrupt(A5);
94 | }
95 |
96 | #define IS_PINCHANGE 0
97 | #define IS_EXTERNAL 1
98 | #define FLIP 0
99 | #define FLOP 1
100 | uint8_t pin3state=IS_PINCHANGE;
101 | uint8_t enabledToggle=FLOP;
102 | uint8_t toggleCounter=0;
103 | // In the loop, we just check to see where the interrupt count is at. The value gets updated by
104 | // the interrupt routine.
105 | void loop() {
106 | if (toggleCounter & 0x10) {
107 | EI_printPSTR("Toggle 2, 3, 8, A0...");
108 | delay(200);
109 | if (enabledToggle==FLOP) {
110 | if (pin3state==IS_PINCHANGE)
111 | disablePCInterrupt(3);
112 | else
113 | disableInterrupt(3);
114 | disablePCInterrupt(2);
115 | disableInterrupt(8);
116 | disableInterrupt(A0);
117 | enabledToggle=FLIP;
118 | }
119 | else {
120 | EI_printPSTR("3 is now a");
121 | if (pin3state == IS_PINCHANGE) {
122 | setupExInterrupt(3);
123 | EI_printPSTR("n external interrupt.\r\n");
124 | pin3state=IS_EXTERNAL;
125 | } else {
126 | setupExInterrupt(3);
127 | EI_printPSTR(" pin change interrupt.\r\n");
128 | pin3state=IS_PINCHANGE;
129 | }
130 | setupPCInterrupt(2);
131 | setupInterrupt(8);
132 | setupInterrupt(A0);
133 | enabledToggle=FLOP;
134 | }
135 | toggleCounter=0;
136 | }
137 | // Bug: 0 is not (technically) a proper test because (technically) we have Arduino pin 0.
138 | // But we don't support pin 0 in this sketch (it's used for Serial print).
139 | if (pinChangeInterruptFlag) {
140 | EI_printPSTR("Pin Change interrupt, pin "); Serial.println(pinChangeInterruptFlag);
141 | pinChangeInterruptFlag=0;
142 | toggleCounter++;
143 | }
144 | if (externalInterruptFlag) {
145 | EI_printPSTR("External interrupt, pin "); Serial.println(externalInterruptFlag);
146 | externalInterruptFlag=0;
147 | toggleCounter++;
148 | }
149 | }
150 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/examples/InterruptedPin328/Makefile:
--------------------------------------------------------------------------------
1 | # Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!)
2 | BOARD_TAG = atmega328
3 | ARDUINO_PORT = /dev/ttyUSB0
4 | #BOARD_TAG = 2560
5 | #ARDUINO_PORT = /dev/ttyACM0
6 | ARDUINO_LIBS =
7 | AVR_TOOLS_DIR = /usr
8 |
9 | CFLAGS_STD = -g
10 | CXXFLAGS_STD = -g
11 |
12 | include /usr/share/arduino/Arduino.mk
13 |
14 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/examples/OOSimple/Makefile:
--------------------------------------------------------------------------------
1 | # Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!)
2 | BOARD_TAG = atmega328
3 | ARDUINO_PORT = /dev/ttyUSB0
4 | #BOARD_TAG = 2560
5 | #ARDUINO_PORT = /dev/ttyACM0
6 | ARDUINO_LIBS =
7 | AVR_TOOLS_DIR = /usr
8 |
9 | CFLAGS_STD = -g
10 | CXXFLAGS_STD = -g
11 |
12 | include /usr/share/arduino/Arduino.mk
13 |
14 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/examples/OOSimple/OOSimple.ino:
--------------------------------------------------------------------------------
1 | // EnableInterrupt OOSimple object-oriented example sketch.
2 | // See https://github.com/GreyGnome/EnableInterrupt and the README.md for more information.
3 |
4 | #include
5 |
6 | // Modify this at your leisure. See https://github.com/GreyGnome/EnableInterrupt/wiki/Usage#Summary
7 | #define ARDUINOPIN 8
8 |
9 | class Simple {
10 |
11 | public:
12 | Simple() {
13 | init();
14 | }
15 | void updateSimpleVariable();
16 | uint8_t getSimpleVariable();
17 |
18 | private:
19 | volatile uint8_t _sv; // a simple variable. Notice that it is volatile.
20 | void init();
21 | };
22 |
23 | void Simple::init() {
24 | _sv=0;
25 | }
26 | void Simple::updateSimpleVariable() {
27 | _sv++;
28 | }
29 |
30 | uint8_t Simple::getSimpleVariable() {
31 | return _sv;
32 | }
33 |
34 | extern "C" void *createSimple() {
35 | return new Simple();
36 | }
37 |
38 | extern "C" uint8_t getSimpleVariable(void *anObject) {
39 | return static_cast(anObject)->getSimpleVariable();
40 | }
41 |
42 | extern "C" void updateSimpleVariable(void *anObject) {
43 | static_cast(anObject)->updateSimpleVariable();
44 | }
45 |
46 | void *simpleObject0; // this is numbered 0. You can create more, for example void *simpleObject1
47 |
48 | // If you create more objects, you need to create more interruptFunctionN()'s
49 | // that update their simple variables, for example interruptFunction1() .
50 | extern "C" void interruptFunction0() {
51 | updateSimpleVariable(simpleObject0);
52 | }
53 |
54 | // Attach the interrupt in setup()
55 | void setup() {
56 | Serial.begin(115200);
57 | Serial.println("---------------------------------------");
58 |
59 | // If you want to enable more pins, you will need to recreate these 3 lines for
60 | // your new pin, object, and function.
61 | pinMode(ARDUINOPIN, INPUT_PULLUP); // See http://arduino.cc/en/Tutorial/DigitalPins
62 | simpleObject0 = createSimple();
63 | enableInterrupt(ARDUINOPIN, interruptFunction0, CHANGE);
64 | }
65 |
66 | // In the loop, we just print our object's simple variable. It is updated by the interrupt routine.
67 | void loop() {
68 | Serial.println("---------------------------------------");
69 | delay(1000); // Every second,
70 | Serial.print("Pin was interrupted: ");
71 | Serial.print(getSimpleVariable(simpleObject0), DEC); // print the interrupt count.
72 | Serial.println(" times so far.");
73 | }
74 |
75 | //////////////////////////////////////////////////////////////////////////////////////////
76 | //////////////////////////////////////// GORY DETAILS //////////////////////////////////////
77 | // This example demonstrates the use of the EnableInterrupt library on a single pin of your choice.
78 | // It demonstrates calling an object's method from an interrupt. Other objects can be created and called
79 | // by simply and creating more simpleObjectN's adding more interruptFunctionN()'s.
80 | //
81 | // This has only been tested on an Arduino Duemilanove and Mega ADK.
82 | // It is designed to work with the Arduino Duemilanove/Uno, Arduino Mega2560/ADK, the Arduino
83 | // Leonardo, and the Arduino Due. Please let me know how you fare on the Leonardo or Due.
84 |
85 | // To use:
86 |
87 | // 1. You must be using a fairly recent version of the Arduino IDE software on your PC/Mac,
88 | // that is, version 1.0.1 or later. Check Help->About Arduino in the IDE.
89 |
90 | // 2. Wire a simple switch to any Analog or Digital pin (known as ARDUINOPIN, defined below)
91 | // that supports interrupts. See https://github.com/GreyGnome/EnableInterrupt/wiki/Usage#Summary
92 | // Attach the other end to a GND pin. A "single pole single throw momentary contact normally
93 | // open" // pushbutton switch is best for the most interrupting fun.
94 | // See https://www.sparkfun.com/products/97 and https://octopart.com/b3f-1000-omron-3117
95 |
96 | // 3. When pressed, the switch will connect the pin to ground ("low", or "0") voltage, and interrupt the
97 | // processor. See http://arduino.cc/en/Tutorial/DigitalPins
98 |
99 | // 4. The interrupt is serviced immediately, and the ISR (Interrupt SubRoutine) sets the value of a global
100 | // variable. Open Tools->Serial Monitor in the IDE to see the results of your interrupts.
101 |
102 | // 5. Peruse the Examples directory for more elaborate examples.
103 |
104 | // 6. Create your own sketch using the EnableInterrupt library!
105 |
106 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/examples/Simple/Makefile:
--------------------------------------------------------------------------------
1 | # Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!)
2 | BOARD_TAG = atmega328
3 | ARDUINO_PORT = /dev/ttyUSB0
4 | #BOARD_TAG = 2560
5 | #ARDUINO_PORT = /dev/ttyACM0
6 | ARDUINO_LIBS =
7 | AVR_TOOLS_DIR = /usr
8 |
9 | CFLAGS_STD = -g
10 | CXXFLAGS_STD = -g
11 |
12 | include /usr/share/arduino/Arduino.mk
13 |
14 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/examples/Simple/Simple.ino:
--------------------------------------------------------------------------------
1 | // EnableInterrupt Simple example sketch. Demonstrates operation on a single pin of your choice.
2 | // See https://github.com/GreyGnome/EnableInterrupt and the README.md for more information.
3 | #include
4 |
5 | // Modify this at your leisure. Refer to https://github.com/GreyGnome/EnableInterrupt/wiki/Usage#Summary
6 | #define ARDUINOPIN 10
7 |
8 | volatile uint16_t interruptCount=0; // The count will go back to 0 after hitting 65535.
9 |
10 | void interruptFunction() {
11 | interruptCount++;
12 | }
13 |
14 | void setup() {
15 | Serial.begin(115200);
16 | pinMode(ARDUINOPIN, INPUT_PULLUP); // See http://arduino.cc/en/Tutorial/DigitalPins
17 | enableInterrupt(ARDUINOPIN, interruptFunction, CHANGE);
18 | }
19 |
20 | // In the loop we just display interruptCount. The value is updated by the interrupt routine.
21 | void loop() {
22 | Serial.println("---------------------------------------");
23 | delay(1000);
24 | Serial.print("Pin was interrupted: ");
25 | Serial.print(interruptCount, DEC);
26 | Serial.println(" times so far.");
27 | }
28 |
29 | //////////////////////////////////////////////////////////////////////////////////////////
30 | ////////////////////////////////////// GORY DETAILS //////////////////////////////////////
31 | // This has only been tested on an Arduino Duemilanove and Mega ADK.
32 | // It is designed to work with the Arduino Duemilanove/Uno, Arduino Mega2560/ADK, the Arduino
33 | // Leonardo, and the Arduino Due. Please let me know how you fare on the Leonardo or Due.
34 |
35 | // To use:
36 |
37 | // 1. You must be using a fairly recent version of the Arduino IDE software on your PC/Mac,
38 | // that is, version 1.0.1 or later. Check Help->About Arduino in the IDE.
39 |
40 | // 2. Wire a simple switch to any Analog or Digital pin (known as ARDUINOPIN, defined below)
41 | // that supports interrupts. See https://github.com/GreyGnome/EnableInterrupt/wiki/Usage#Summary
42 | // Attach the other end to a GND pin. A "single pole single throw momentary contact normally
43 | // open" // pushbutton switch is best for the most interrupting fun.
44 | // See https://www.sparkfun.com/products/97 and https://octopart.com/b3f-1000-omron-3117
45 |
46 | // 3. When pressed, the switch will connect the pin to ground ("low", or "0") voltage, and interrupt the
47 | // processor. See http://arduino.cc/en/Tutorial/DigitalPins
48 |
49 | // 4. The interrupt is serviced immediately, and the ISR (Interrupt SubRoutine) modifies the value of
50 | // the global variable interruptCount. Open Tools->Serial Monitor in the IDE to see the results of your
51 | // interrupts.
52 |
53 | // 5. Peruse the Examples directory for more elaborate examples.
54 |
55 | // 6. Create your own sketch using the EnableInterrupt library!
56 |
57 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/examples/SimpleFunctionWithArg/Makefile:
--------------------------------------------------------------------------------
1 | # Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!)
2 | BOARD_TAG = atmega328
3 | ARDUINO_PORT = /dev/ttyUSB0
4 | #BOARD_TAG = 2560
5 | #ARDUINO_PORT = /dev/ttyACM0
6 | ARDUINO_LIBS =
7 | AVR_TOOLS_DIR = /usr
8 |
9 | CFLAGS_STD = -g
10 | CXXFLAGS_STD = -g
11 |
12 | include /usr/share/arduino/Arduino.mk
13 |
14 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/examples/SimpleFunctionWithArg/SimpleFunctionWithArg.ino:
--------------------------------------------------------------------------------
1 | // EnableInterrupt Simple example sketch. Demonstrates operation on a single pin of your choice.
2 | // See https://github.com/GreyGnome/EnableInterrupt and the README.md for more information.
3 | #define EI_FUNCTION_TAKES_ARG
4 | #include
5 |
6 | // Modify this at your leisure. Refer to https://github.com/GreyGnome/EnableInterrupt/wiki/Usage#Summary
7 | #define ARDUINOPIN 10
8 |
9 | const uint8_t playful_id=ARDUINOPIN;
10 | volatile uint16_t interruptCount=0; // The count will go back to 0 after hitting 65535.
11 | volatile uint8_t latest_id=0;
12 |
13 | void interruptFunction(uint8_t *id) {
14 | interruptCount++;
15 | latest_id=*id;
16 | }
17 |
18 | void setup() {
19 | Serial.begin(115200);
20 | pinMode(ARDUINOPIN, INPUT_PULLUP); // See http://arduino.cc/en/Tutorial/DigitalPins
21 | enableInterrupt(ARDUINOPIN, interruptFunction((void *) &playful_id), CHANGE);
22 | }
23 |
24 |
25 | // In the loop we just display interruptCount. The value is updated by the interrupt routine.
26 | void loop() {
27 | Serial.println("---------------------------------------");
28 | delay(1000);
29 | Serial.print("Pin was interrupted: ");
30 | Serial.print(interruptCount, DEC);
31 | Serial.println(" times so far.");
32 | }
33 |
34 | //////////////////////////////////////////////////////////////////////////////////////////
35 | ////////////////////////////////////// GORY DETAILS //////////////////////////////////////
36 | // This has only been tested on an Arduino Duemilanove and Mega ADK.
37 | // It is designed to work with the Arduino Duemilanove/Uno, Arduino Mega2560/ADK, the Arduino
38 | // Leonardo, and the Arduino Due. Please let me know how you fare on the Leonardo or Due.
39 |
40 | // To use:
41 |
42 | // 1. You must be using a fairly recent version of the Arduino IDE software on your PC/Mac,
43 | // that is, version 1.0.1 or later. Check Help->About Arduino in the IDE.
44 |
45 | // 2. Wire a simple switch to any Analog or Digital pin (known as ARDUINOPIN, defined below)
46 | // that supports interrupts. See https://github.com/GreyGnome/EnableInterrupt/wiki/Usage#Summary
47 | // Attach the other end to a GND pin. A "single pole single throw momentary contact normally
48 | // open" // pushbutton switch is best for the most interrupting fun.
49 | // See https://www.sparkfun.com/products/97 and https://octopart.com/b3f-1000-omron-3117
50 |
51 | // 3. When pressed, the switch will connect the pin to ground ("low", or "0") voltage, and interrupt the
52 | // processor. See http://arduino.cc/en/Tutorial/DigitalPins
53 |
54 | // 4. The interrupt is serviced immediately, and the ISR (Interrupt SubRoutine) modifies the value of
55 | // the global variable interruptCount. Open Tools->Serial Monitor in the IDE to see the results of your
56 | // interrupts.
57 |
58 | // 5. Peruse the Examples directory for more elaborate examples.
59 |
60 | // 6. Create your own sketch using the EnableInterrupt library!
61 |
62 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/examples/Testing/Makefile:
--------------------------------------------------------------------------------
1 | # Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!)
2 | BOARD_TAG = 2560
3 | ARDUINO_PORT = /dev/ttyACM0
4 | ARDUINO_LIBS =
5 | AVR_TOOLS_DIR = /usr
6 |
7 | CFLAGS_STD = -g
8 | CXXFLAGS_STD = -g
9 |
10 | include /usr/share/arduino/Arduino.mk
11 |
12 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/extras/NOTICE:
--------------------------------------------------------------------------------
1 | NOTICE
2 | EnableInterrupt Arduino Library
3 | Copyright 2014-2015 Michael Schwager (aka Mike Schwager aka "GreyGnome")
4 |
5 | This product includes software developed by Mike Schwager.
6 |
7 | This library was inspired and replaces the PinChangeInt library.
8 |
9 | GreyGnome is the current maintainer, and would like to thank all those
10 | Open Source coders, the Arduino makers and community, and especially Chris
11 | and Lex for lighting the flame and showing the way! And a big thank you to
12 | the users who have contributed comments and bug fixes along the way.
13 | Without you this project would not have overcome some significant hurdles.
14 |
15 | A HUGE thanks to Jan Baeyens ("jantje"), who has graciously DONATED an
16 | Arduino Mega ADK board to the PinChangeInt project!!! Wow, thanks Jan!
17 | This makes the 2560-based Arduino Mega a first class supported platform-
18 | I am able to test it and verify that it works.
19 |
20 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/extras/RELEASE_NOTES:
--------------------------------------------------------------------------------
1 | Sat Aug 8 12:03:24 CDT 2015
2 | Version 0.8.1. I forgot to include some fixes for an issue on the website; https://github.com/GreyGnome/EnableInterrupt/issues/13 (having to do with the 1284 chip). These are now included.
3 |
4 | Fri Aug 7 06:44:55 CDT 2015
5 | Version 0.8.0. This release includes the function to set a variable that can be queried by the programmer's
6 | ISR, to determine which pin was interrupted. Define EI_ARDUINO_INTERRUPTED_PIN in the main sketch.
7 |
8 | Also:
9 | My Mega2560 failed right in the middle of testing this release. So that platform is not fully tested.
10 | The InterruptedPin2560.ino sketch was giving me some inconsistent results: I saw pin 71 interrupted twice,
11 | and pin 70 not at all. I think there is a bug in utility/ei_PinChange2560.h, but I will release before I resolve
12 | this. If there is anyone who could test on the 2560 platform- run the InterruptedPin2560.ino sketch and send me
13 | the output- I would appreciate it.
14 |
15 | Mon Jul 6 17:41:05 CDT 2015
16 | This release includes compiler directives that allow you to eliminate unneeded ports and memory allocations, to more efficiently utilize code and static RAM. See https://github.com/GreyGnome/EnableInterrupt/wiki/SaveMemory for the new features.
17 |
18 | Tue Jun 23 06:47:10 CDT 2015
19 | Version 0.6.3 of the library has been released. This release includes an Object Oriented example, OOSimple, in the examples/ directory. There are no other changes since version 0.6.2.
20 |
21 | Fri Jun 19 09:38:43 CDT 2015
22 | Version 0.6.2. Forgot to update README.md.
23 |
24 | Fri Jun 12 06:33:20 CDT 2015
25 | Version 0.6.1 of the library has been released. This version is designed to meet the requirements of the 1.5.x Arduino library spec. No code logic was modified; only files were moved and library.properties and keywords.txt files added.
26 |
27 | Version 0.6.0 did not include an update to these release notes.
28 |
29 | Fri Jun 12 06:33:20 CDT 2015
30 | Version 0.5 (Alpha) of the library has been released. This release includes support for the ATmega1284p line of processors (includes ATmega644). The Mighty 1284 is used as the basis. As I don't have a 1284-based processor, this code compiles but has not been tested (see examples/Might1284p). Bug reports encouraged and welcomed! It would be great if a 644/1284 owner could upload the Might1284p.ino sketch and interrupt every pin and let me know the results.
31 |
32 | Code was refactored so that a lot of utility routines were moved into individual .h files. Now there's a lot of files, which appears ugly, but the old way was a lot uglier to my mind and looked like a big bowl of spaghetti with so many #ifdefs strewn about to handle the different chips. It was getting hard to wade through the code.
33 |
34 | Fri May 8 07:33:26 CDT 2015
35 | Version 0.4 - New high speed ("HiSpeed") mode. In this mode, the interrupt routine is predefined:
36 | it ONLY updates a variable. This knocks a couple of microseconds off of the interrupt
37 | routine times; it greatly reduces the number of registers needed to be pushed/popped, and
38 | of course does not require a function call. See the wiki for details, including speed measurements.
39 |
40 | Mon Apr 13 07:49:05 CDT 2015
41 | Version 0.3 - Arjun reported a bug on the Uno platform:
42 |
43 | In file included from Interrupt.ino:1:
44 | /Users/arjunmehta94/Documents/Arduino/libraries/EnableInterrupt-master/EnableInterrupt.h: In function 'void __vector_3()':
45 | /Users/arjunmehta94/Documents/Arduino/libraries/EnableInterrupt-master/EnableInterrupt.h:976: error: 'struct functionPointersPortB' has no member named 'pinSix'
46 | /Users/arjunmehta94/Documents/Arduino/libraries/EnableInterrupt-master/EnableInterrupt.h:977: error: 'struct functionPointersPortB' has no member named 'pinSeven'
47 |
48 | I have a Duemilanove; I don't know why I never saw that error. Regardless, I have included some
49 | #ifndef lines in to protect that code from getting compiled.
50 |
51 | Also added RELEASE_NOTES to the zip file, and to Git.
52 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/utility/ei_External1284.h:
--------------------------------------------------------------------------------
1 | #if ! defined(EI_NOTINT0) && ! defined (EI_NOTINT1) && ! defined (EI_NOTINT2)
2 | #ifdef EI_SECTION_ENABLEEXTERNAL
3 | switch (arduinoPin) {
4 | #ifndef EI_NOTINT0
5 | case 10 : // INT0
6 | EIMSK &= ~_BV(0);
7 | #ifndef NEEDFORSPEED
8 | functionPointerArrayEXTERNAL[0] = userFunction;
9 | #endif
10 | EICRA &= (~_BV(0) & ~_BV(1)); // reset the flags prior to
11 | EICRA |= mode; // set them the way we want
12 | EIFR |= _BV(0);
13 | EIMSK |= _BV(0);
14 | break;
15 | #endif
16 | #ifndef EI_NOTINT1
17 | case 11 : // INT1
18 | EIMSK &= ~_BV(1);
19 | #ifndef NEEDFORSPEED
20 | functionPointerArrayEXTERNAL[1] = userFunction;
21 | #endif
22 | EICRA &= (~_BV(2) & ~_BV(3));
23 | EICRA |= (mode << 2);
24 | EIFR |= _BV(1);
25 | EIMSK |= _BV(1);
26 | break;
27 | #endif
28 | #ifndef EI_NOTINT2
29 | case 2 : // INT2
30 | EIMSK &= ~_BV(2);
31 | #ifndef NEEDFORSPEED
32 | functionPointerArrayEXTERNAL[2] = userFunction;
33 | #endif
34 | EICRA &= (~_BV(4) & ~_BV(5));
35 | EICRA |= (mode << 4);
36 | EIFR |= _BV(2);
37 | EIMSK |= _BV(2);
38 | break;
39 | #endif
40 | }
41 | #endif // EI_SECTION_ENABLEEXTERNAL
42 |
43 | #ifdef EI_SECTION_DISABLEEXTERNAL
44 | #ifndef EI_NOTINT0
45 | if (arduinoPin == 10) {
46 | EIMSK &= ~_BV(0);
47 | EICRA &= (~_BV(0) & ~_BV(1));
48 | EIFR |= _BV(0); // using a clue from the ATmega2560 datasheet.
49 | }
50 | #endif
51 | #ifndef EI_NOTINT1
52 | if (arduinoPin == 11) {
53 | EIMSK &= ~_BV(1);
54 | EICRA &= (~_BV(2) & ~_BV(3));
55 | EIFR |= _BV(1); // using a clue from the ATmega2560 datasheet.
56 | }
57 | #endif
58 | #ifndef EI_NOTINT2
59 | if (arduinoPin == 2) {
60 | EIMSK &= ~_BV(2);
61 | EICRA &= (~_BV(4) & ~_BV(5));
62 | EIFR |= _BV(2); // using a clue from the ATmega2560 datasheet.
63 | }
64 | #endif
65 | #endif // EI_SECTION_DISABLEEXTERNAL
66 | #endif // ! defined(EI_NOTINT0) && ! defined (EI_NOTINT1) && ! defined (EI_NOTINT2)
67 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/utility/ei_External2560.h:
--------------------------------------------------------------------------------
1 | #if ! defined(EI_NOTINT0) && ! defined(EI_NOTINT1) && ! defined(EI_NOTINT2) && ! defined(EI_NOTINT3) && ! defined(EI_NOTINT4) && ! defined(EI_NOTINT5) && ! defined(EI_NOTINT6) && ! defined(EI_NOTINT7)
2 | #ifdef EI_SECTION_ENABLEEXTERNAL
3 | switch (arduinoPin) {
4 | #ifndef EI_NOTINT0
5 | case 21 : // INT0
6 | #ifndef NEEDFORSPEED
7 | functionPointerArrayEXTERNAL[0] = userFunction;
8 | #endif
9 | EIMSK &= ~_BV(0);
10 | EICRA &= (~_BV(0) & ~_BV(1));
11 | EICRA |= mode;
12 | EIFR |= _BV(0);
13 | EIMSK |= _BV(0);
14 | break;
15 | #endif
16 | #ifndef EI_NOTINT1
17 | case 20 : // INT1
18 | #ifndef NEEDFORSPEED
19 | functionPointerArrayEXTERNAL[1] = userFunction;
20 | #endif
21 | EIMSK &= ~_BV(1);
22 | EICRA &= (~_BV(2) & ~_BV(3));
23 | EICRA |= (mode << 2);
24 | EIFR |= _BV(1);
25 | EIMSK |= _BV(1);
26 | break;
27 | #endif
28 | #ifndef EI_NOTINT2
29 | case 19 : // INT2
30 | #ifndef NEEDFORSPEED
31 | functionPointerArrayEXTERNAL[2] = userFunction;
32 | #endif
33 | EIMSK &= ~_BV(2);
34 | EICRA &= (~_BV(4) & ~_BV(5));
35 | EICRA |= (mode << 4);
36 | EIFR |= _BV(2);
37 | EIMSK |= _BV(2);
38 | break;
39 | #endif
40 | #ifndef EI_NOTINT3
41 | case 18 : // INT3
42 | #ifndef NEEDFORSPEED
43 | functionPointerArrayEXTERNAL[3] = userFunction;
44 | #endif
45 | EIMSK &= ~_BV(3);
46 | EICRA &= (~_BV(6) & ~_BV(7));
47 | EICRA |= (mode << 6);
48 | EIFR |= _BV(3);
49 | EIMSK |= _BV(3);
50 | break;
51 | #endif
52 | #ifndef EI_NOTINT4
53 | case 2 : // INT4
54 | #ifndef NEEDFORSPEED
55 | functionPointerArrayEXTERNAL[4] = userFunction;
56 | #endif
57 | EIMSK &= ~_BV(4);
58 | EICRB &= (~_BV(0) & ~_BV(1));
59 | EICRB |= mode;
60 | EIFR |= _BV(4);
61 | EIMSK |= _BV(4);
62 | break;
63 | #endif
64 | #ifndef EI_NOTINT5
65 | case 3 : // INT5
66 | #ifndef NEEDFORSPEED
67 | functionPointerArrayEXTERNAL[5] = userFunction;
68 | #endif
69 | EIMSK &= ~_BV(5);
70 | EICRB &= (~_BV(2) & ~_BV(3));
71 | EICRB |= (mode << 2);
72 | EIFR |= _BV(5);
73 | EIMSK |= _BV(5);
74 | break;
75 | #endif
76 | #ifndef EI_NOTINT6
77 | case 75 : // INT6- Fake Arduino Pin
78 | #ifndef NEEDFORSPEED
79 | functionPointerArrayEXTERNAL[6] = userFunction;
80 | #endif
81 | EIMSK &= ~_BV(6);
82 | EICRB &= (~_BV(4) & ~_BV(5));
83 | EICRB |= (mode << 4);
84 | EIFR |= _BV(6);
85 | EIMSK |= _BV(6);
86 | break;
87 | #endif
88 | #ifndef EI_NOTINT7
89 | case 76 : // INT7- Fake Arduino Pin
90 | #ifndef NEEDFORSPEED
91 | functionPointerArrayEXTERNAL[7] = userFunction;
92 | #endif
93 | EIMSK &= ~_BV(7);
94 | EICRB &= (~_BV(6) & ~_BV(7));
95 | EICRB |= (mode << 6);
96 | EIFR |= _BV(7);
97 | EIMSK |= _BV(7);
98 | break;
99 | #endif
100 | }
101 | #endif // EI_SECTION_ENABLEEXTERNAL
102 |
103 | #ifdef EI_SECTION_DISABLEEXTERNAL
104 | switch (arduinoPin) {
105 | #ifndef EI_NOTINT0
106 | case 21 : // INT0
107 | EIMSK &= ~_BV(0);
108 | EICRA &= (~_BV(0) & ~_BV(1));
109 | EIFR |= _BV(0);
110 | break;
111 | #endif
112 | #ifndef EI_NOTINT1
113 | case 20 : // INT1
114 | EIMSK &= ~_BV(1);
115 | EICRA &= (~_BV(2) & ~_BV(3));
116 | EIFR |= _BV(1);
117 | break;
118 | #endif
119 | #ifndef EI_NOTINT2
120 | case 19 : // INT2
121 | EIMSK &= ~_BV(2);
122 | EICRA &= (~_BV(4) & ~_BV(5));
123 | EIFR |= _BV(2);
124 | break;
125 | #endif
126 | #ifndef EI_NOTINT3
127 | case 18 : // INT3
128 | EIMSK &= ~_BV(3);
129 | EICRA &= (~_BV(6) & ~_BV(7));
130 | EIFR |= _BV(3);
131 | break;
132 | #endif
133 | #ifndef EI_NOTINT4
134 | case 2 : // INT4
135 | EIMSK &= ~_BV(4);
136 | EICRB &= (~_BV(0) & ~_BV(1));
137 | EIFR |= _BV(4);
138 | break;
139 | #endif
140 | #ifndef EI_NOTINT5
141 | case 3 : // INT5
142 | EIMSK &= ~_BV(5);
143 | EICRB &= (~_BV(2) & ~_BV(3));
144 | EIFR |= _BV(5);
145 | break;
146 | #endif
147 | #ifndef EI_NOTINT6
148 | case 75 : // INT6- Fake Arduino Pin
149 | EIMSK &= ~_BV(6);
150 | EICRB &= (~_BV(4) & ~_BV(5));
151 | EIFR |= _BV(6);
152 | break;
153 | #endif
154 | #ifndef EI_NOTINT7
155 | case 76 : // INT7- Fake Arduino Pin
156 | EIMSK &= ~_BV(7);
157 | EICRB &= (~_BV(6) & ~_BV(7));
158 | EIFR |= _BV(7);
159 | break;
160 | #endif
161 | }
162 | #endif // EI_SECTION_DISABLEEXTERNAL
163 | #endif // ! defined(EI_NOTINT0) && ! defined(EI_NOTINT1) && ! defined(EI_NOTINT2) && ! defined(EI_NOTINT3) && ! defined(EI_NOTINT4) && ! defined(EI_NOTINT5) && ! defined(EI_NOTINT6) && ! defined(EI_NOTINT7)
164 |
165 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/utility/ei_External328.h:
--------------------------------------------------------------------------------
1 | #if ! defined(EI_NOTINT0) && ! defined(EI_NOTINT1)
2 | #ifdef EI_SECTION_ENABLEEXTERNAL
3 | #ifndef EI_NOTINT0
4 | if (arduinoPin == 2) {
5 | #ifndef NEEDFORSPEED
6 | functionPointerArrayEXTERNAL[0] = userFunction;
7 | #endif
8 | EIMSK &= ~_BV(0);
9 | EICRA &= (~_BV(0) & ~_BV(1));
10 | EICRA |= mode;
11 | EIFR |= _BV(0); // using a clue from the ATmega2560 datasheet.
12 | EIMSK |= _BV(0);
13 | }
14 | #endif
15 | #ifndef EI_NOTINT1
16 | if (arduinoPin == 3) {
17 | #ifndef NEEDFORSPEED
18 | functionPointerArrayEXTERNAL[1] = userFunction;
19 | #endif
20 | EIMSK &= ~_BV(1);
21 | EICRA &= (~_BV(2) & ~_BV(3));
22 | EICRA |= mode << 2;
23 | EIFR |= _BV(1); // using a clue from the ATmega2560 datasheet.
24 | EIMSK |= _BV(1);
25 | }
26 | #endif
27 | #endif // EI_SECTION_ENABLEEXTERNAL
28 |
29 | #ifdef EI_SECTION_DISABLEEXTERNAL
30 | #ifndef EI_NOTINT0
31 | if (arduinoPin == 2) {
32 | EIMSK &= ~_BV(0);
33 | EICRA &= (~_BV(0) & ~_BV(1));
34 | EIFR |= _BV(0); // using a clue from the ATmega2560 datasheet.
35 | }
36 | #endif
37 | #ifndef EI_NOTINT1
38 | if (arduinoPin == 3) {
39 | EIMSK &= ~_BV(1);
40 | EICRA &= (~_BV(2) & ~_BV(3));
41 | EIFR |= _BV(1); // using a clue from the ATmega2560 datasheet.
42 | }
43 | #endif
44 | #endif // EI_SECTION_DISABLEEXTERNAL
45 | #endif // ! defined(EI_NOTINT0) && ! defined(EI_NOTINT1)
46 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/utility/ei_ExternalLeonardo.h:
--------------------------------------------------------------------------------
1 | #if ! defined(EI_NOTINT0) && ! defined(EI_NOTINT1) && ! defined(EI_NOTINT2) && ! defined(EI_NOTINT3) && ! defined(EI_NOTINT6)
2 | #ifdef EI_SECTION_ENABLEEXTERNAL
3 | switch (arduinoPin) {
4 | #ifndef EI_NOTINT0
5 | case 3 : // INT0
6 | #ifndef NEEDFORSPEED
7 | functionPointerArrayEXTERNAL[0] = userFunction;
8 | #endif
9 | EIMSK &= ~_BV(0);
10 | EICRA &= (~_BV(0) & ~_BV(1));
11 | EICRA |= mode;
12 | EIFR |= _BV(0);
13 | EIMSK |= _BV(0);
14 | break;
15 | #endif
16 | #ifndef EI_NOTINT1
17 | case 2 : // INT1
18 | #ifndef NEEDFORSPEED
19 | functionPointerArrayEXTERNAL[1] = userFunction;
20 | #endif
21 | EIMSK &= ~_BV(1);
22 | EICRA &= (~_BV(2) & ~_BV(3));
23 | EICRA |= (mode << 2);
24 | EIFR |= _BV(1);
25 | EIMSK |= _BV(1);
26 | break;
27 | #endif
28 | #ifndef EI_NOTINT2
29 | case 0 : // INT2
30 | #ifndef NEEDFORSPEED
31 | functionPointerArrayEXTERNAL[2] = userFunction;
32 | #endif
33 | EIMSK &= ~_BV(2);
34 | EICRA &= (~_BV(4) & ~_BV(5));
35 | EICRA |= (mode << 4);
36 | EIFR |= _BV(2);
37 | EIMSK |= _BV(2);
38 | break;
39 | #endif
40 | #ifndef EI_NOTINT3
41 | case 1 : // INT3
42 | #ifndef NEEDFORSPEED
43 | functionPointerArrayEXTERNAL[3] = userFunction;
44 | #endif
45 | EIMSK &= ~_BV(3);
46 | EICRA &= (~_BV(6) & ~_BV(7));
47 | EICRA |= (mode << 6);
48 | EIFR |= _BV(3);
49 | EIMSK |= _BV(3);
50 | break;
51 | #endif
52 | #ifndef EI_NOTINT6
53 | case 7 : // INT6
54 | #ifndef NEEDFORSPEED
55 | functionPointerArrayEXTERNAL[4] = userFunction;
56 | #endif
57 | EIMSK &= ~_BV(6);
58 | EICRB &= (~_BV(4) & ~_BV(5));
59 | EICRB |= (mode << 4);
60 | EIFR |= _BV(6);
61 | EIMSK |= _BV(6);
62 | break;
63 | #endif
64 | }
65 | #endif // EI_SECTION_ENABLEEXTERNAL
66 |
67 | #ifdef EI_SECTION_DISABLEEXTERNAL
68 | switch (arduinoPin) {
69 | #ifndef EI_NOTINT0
70 | case 3 : // INT0
71 | EIMSK &= ~_BV(0);
72 | EICRA &= (~_BV(0) & ~_BV(1));
73 | EIFR |= _BV(0);
74 | break;
75 | #endif
76 | #ifndef EI_NOTINT1
77 | case 2 : // INT1
78 | EIMSK &= ~_BV(1);
79 | EICRA &= (~_BV(2) & ~_BV(3));
80 | EIFR |= _BV(1);
81 | break;
82 | #endif
83 | #ifndef EI_NOTINT2
84 | case 0 : // INT2
85 | EIMSK &= ~_BV(2);
86 | EICRA &= (~_BV(4) & ~_BV(5));
87 | EIFR |= _BV(2);
88 | break;
89 | #endif
90 | #ifndef EI_NOTINT3
91 | case 1 : // INT3
92 | EIMSK &= ~_BV(3);
93 | EICRA &= (~_BV(6) & ~_BV(7));
94 | EIFR |= _BV(3);
95 | break;
96 | #endif
97 | #ifndef EI_NOTINT6
98 | case 7 : // INT6
99 | EIMSK &= ~_BV(6);
100 | EICRB &= (~_BV(4) & ~_BV(5));
101 | EIFR |= _BV(6);
102 | break;
103 | #endif
104 | }
105 | #endif // EI_SECTION_DISABLEEXTERNAL
106 | #endif // ! defined(EI_NOTINT0) && ! defined(EI_NOTINT1) && ! defined(EI_NOTINT2) && ! defined(EI_NOTINT3) && ! defined(EI_NOTINT6)
107 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/utility/ei_PinChange1284.h:
--------------------------------------------------------------------------------
1 | #ifdef EI_SECTION_RISING
2 | #ifndef EI_NOTPORTA
3 | if (portNumber==PA) {
4 | risingPinsPORTA |= portMask;
5 | }
6 | #endif
7 | #ifndef EI_NOTPORTB
8 | if (portNumber==PB) {
9 | risingPinsPORTB |= portMask;
10 | }
11 | #endif
12 | #ifndef EI_NOTPORTC
13 | if (portNumber==PC) {
14 | risingPinsPORTC |= portMask;
15 | }
16 | #endif
17 | #ifndef EI_NOTPORTD
18 | if (portNumber==PD) {
19 | risingPinsPORTD |= portMask;
20 | }
21 | #endif
22 | #endif // EI_SECTION_RISING
23 |
24 | #ifdef EI_SECTION_FALLING
25 | #ifndef EI_NOTPORTA
26 | if (portNumber==PA) {
27 | fallingPinsPORTA |= portMask;
28 | }
29 | #endif
30 | #ifndef EI_NOTPORTB
31 | if (portNumber==PB) {
32 | fallingPinsPORTB |= portMask;
33 | }
34 | #endif
35 | #ifndef EI_NOTPORTC
36 | if (portNumber==PC) {
37 | fallingPinsPORTC |= portMask;
38 | }
39 | #endif
40 | #ifndef EI_NOTPORTD
41 | if (portNumber==PD) {
42 | fallingPinsPORTD |= portMask;
43 | }
44 | #endif
45 | #endif // EI_SECTION_FALLING
46 |
47 | #if defined EI_SECTION_ASSIGNFUNCTIONSREGISTERS
48 | #ifndef EI_NOTPORTA
49 | if (portNumber==PA) {
50 | #ifndef NEEDFORSPEED
51 | calculatedPointer=&portAFunctions.pinZero + portBitNumber;
52 | *calculatedPointer = userFunction;
53 | #endif
54 | portSnapshotA=*portInputRegister(portNumber);
55 | pcmsk=&PCMSK0;
56 | PCICR |= _BV(0);
57 | }
58 | #endif
59 | #ifndef EI_NOTPORTB
60 | if (portNumber==PB) {
61 | #ifndef NEEDFORSPEED
62 | calculatedPointer=&portBFunctions.pinZero + portBitNumber;
63 | *calculatedPointer = userFunction;
64 | #endif
65 | portSnapshotB=*portInputRegister(portNumber);
66 | pcmsk=&PCMSK1;
67 | PCICR |= _BV(1);
68 | }
69 | #endif
70 | #ifndef EI_NOTPORTC
71 | if (portNumber==PC) {
72 | #ifndef NEEDFORSPEED
73 | calculatedPointer=&portCFunctions.pinZero + portBitNumber;
74 | *calculatedPointer = userFunction;
75 | #endif
76 | portSnapshotC=*portInputRegister(portNumber);
77 | pcmsk=&PCMSK2;
78 | PCICR |= _BV(2);
79 | }
80 | #endif
81 | #ifndef EI_NOTPORTD
82 | if (portNumber==PD) {
83 | #ifndef NEEDFORSPEED
84 | calculatedPointer=&portDFunctions.pinZero + portBitNumber;
85 | *calculatedPointer = userFunction;
86 | #endif
87 | portSnapshotD=*portInputRegister(portNumber);
88 | pcmsk=&PCMSK3;
89 | PCICR |= _BV(3);
90 | }
91 | #endif
92 | #endif // EI_SECTION_ASSIGNFUNCTIONSREGISTERS
93 |
94 | #ifdef EI_SECTION_DISABLEPINCHANGE
95 | #ifndef EI_NOTPORTA
96 | if (portNumber == PA) {
97 | PCMSK0 &= ~portMask;
98 | if (PCMSK0 == 0) { PCICR &= ~_BV(0); };
99 | risingPinsPORTA &= ~portMask;
100 | fallingPinsPORTA &= ~portMask;
101 | }
102 | #endif
103 | #ifndef EI_NOTPORTB
104 | if (portNumber == PB) {
105 | PCMSK1 &= ~portMask;
106 | if (PCMSK1 == 0) { PCICR &= ~_BV(1); };
107 | risingPinsPORTB &= ~portMask;
108 | fallingPinsPORTB &= ~portMask;
109 | }
110 | #endif
111 | #ifndef EI_NOTPORTC
112 | if (portNumber == PC) {
113 | PCMSK2 &= ~portMask;
114 | if (PCMSK2 == 0) { PCICR &= ~_BV(2); };
115 | risingPinsPORTC &= ~portMask;
116 | fallingPinsPORTC &= ~portMask;
117 | }
118 | #endif
119 | #ifndef EI_NOTPORTD
120 | if (portNumber == PD) {
121 | PCMSK3 &= ~portMask;
122 | if (PCMSK3 == 0) { PCICR &= ~_BV(3); };
123 | risingPinsPORTB &= ~portMask;
124 | fallingPinsPORTB &= ~portMask;
125 | }
126 | #endif
127 | #endif // EI_SECTION_DISABLEPINCHANGE
128 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/utility/ei_PinChange2560.h:
--------------------------------------------------------------------------------
1 | #ifdef EI_SECTION_RISING
2 | #ifndef EI_NOTPORTB
3 | if (portNumber==PB) {
4 | risingPinsPORTB |= portMask;
5 | }
6 | #endif
7 | #ifndef EI_NOTPORTJ
8 | if (portNumber==PJ) {
9 | risingPinsPORTJ |= portMask;
10 | }
11 | #endif
12 | #ifndef EI_NOTPORTK
13 | if (portNumber==PK) {
14 | risingPinsPORTK |= portMask;
15 | }
16 | #endif
17 | #endif
18 |
19 | #ifdef EI_SECTION_FALLING
20 | #ifndef EI_NOTPORTB
21 | if (portNumber==PB) {
22 | fallingPinsPORTB |= portMask;
23 | }
24 | #endif
25 | #ifndef EI_NOTPORTJ
26 | if (portNumber==PJ) {
27 | fallingPinsPORTJ |= portMask;
28 | }
29 | #endif
30 | #ifndef EI_NOTPORTK
31 | if (portNumber==PK) {
32 | fallingPinsPORTK |= portMask;
33 | }
34 | #endif
35 | #endif // EI_SECTION_FALLING
36 |
37 | #ifdef EI_SECTION_ASSIGNFUNCTIONSREGISTERS
38 | #ifndef EI_NOTPORTB
39 | if (portNumber==PB) {
40 | #ifndef NEEDFORSPEED
41 | calculatedPointer=&portBFunctions.pinZero + portBitNumber;
42 | *calculatedPointer = userFunction;
43 | #endif
44 | portSnapshotB=*portInputRegister(portNumber);
45 | pcmsk=&PCMSK0;
46 | PCICR |= _BV(0);
47 | }
48 | #endif
49 | #ifndef EI_NOTPORTJ
50 | if (portNumber==PJ) {
51 | #ifndef NEEDFORSPEED
52 | calculatedPointer=&portJFunctions.pinZero + portBitNumber;
53 | *calculatedPointer = userFunction;
54 | #endif
55 | portSnapshotJ=*portInputRegister(portNumber);
56 | pcmsk=&PCMSK1;
57 | PCICR |= _BV(1);
58 | // TODO: I think the order of these is flipped. Test. BUG??? -Mike
59 | portJPCMSK|=portMask; // because PCMSK1 is shifted wrt. PortJ.
60 | portMask <<= 1; // Handle port J's oddness. PJ0 is actually 1 on PCMSK1.
61 | }
62 | #endif
63 | #ifndef EI_NOTPORTK
64 | if (portNumber==PK) {
65 | #ifndef NEEDFORSPEED
66 | calculatedPointer=&portKFunctions.pinZero + portBitNumber;
67 | *calculatedPointer = userFunction;
68 | #endif
69 | portSnapshotK=*portInputRegister(portNumber);
70 | pcmsk=&PCMSK2;
71 | PCICR |= _BV(2);
72 | }
73 | #endif
74 | #endif // EI_SECTION_ASSIGNFUNCTIONSREGISTERS
75 |
76 | #ifdef EI_SECTION_DISABLEPINCHANGE
77 | #ifndef EI_NOTPORTB
78 | if (portNumber == PB) {
79 | PCMSK0 &= ~portMask;
80 | if (PCMSK0 == 0) { PCICR &= ~_BV(0); };
81 | risingPinsPORTB &= ~portMask;
82 | fallingPinsPORTB &= ~portMask;
83 | }
84 | #endif
85 | #ifndef EI_NOTPORTJ
86 | if (portNumber == PJ) {
87 | // Handle port J's oddness. PJ0 is actually 1 on PCMSK1.
88 | PCMSK1 &= ((~portMask << 1) | 0x01); // or with 1 to not touch PE0.
89 | if (PCMSK1 == 0) { PCICR &= ~_BV(1); };
90 | risingPinsPORTJ &= ~portMask;
91 | fallingPinsPORTJ &= ~portMask;
92 | }
93 | #endif
94 | #ifndef EI_NOTPORTK
95 | if (portNumber == PK) {
96 | PCMSK2 &= ~portMask;
97 | if (PCMSK2 == 0) { PCICR &= ~_BV(2); };
98 | risingPinsPORTK &= ~portMask;
99 | fallingPinsPORTK &= ~portMask;
100 | }
101 | #endif
102 | #endif // EI_SECTION_DISABLEPINCHANGE
103 |
104 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/utility/ei_PinChange328.h:
--------------------------------------------------------------------------------
1 | #ifdef EI_SECTION_RISING
2 | #ifndef EI_NOTPORTB
3 | if (portNumber==PB) {
4 | risingPinsPORTB |= portMask;
5 | }
6 | #endif
7 | #ifndef EI_NOTPORTC
8 | if (portNumber==PC) {
9 | risingPinsPORTC |= portMask;
10 | }
11 | #endif
12 | #ifndef EI_NOTPORTD
13 | if (portNumber==PD) {
14 | risingPinsPORTD |= portMask;
15 | }
16 | #endif
17 | #endif // EI_SECTION_RISING
18 |
19 | #ifdef EI_SECTION_FALLING
20 | #ifndef EI_NOTPORTB
21 | if (portNumber==PB) {
22 | fallingPinsPORTB |= portMask;
23 | }
24 | #endif
25 | #ifndef EI_NOTPORTC
26 | if (portNumber==PC) {
27 | fallingPinsPORTC |= portMask;
28 | }
29 | #endif
30 | #ifndef EI_NOTPORTD
31 | if (portNumber==PD) {
32 | fallingPinsPORTD |= portMask;
33 | }
34 | #endif
35 | #endif // EI_SECTION_FALLING
36 |
37 | #if defined EI_SECTION_ASSIGNFUNCTIONSREGISTERS
38 | #ifndef EI_NOTPORTB
39 | if (portNumber==PB) {
40 | #ifndef NEEDFORSPEED
41 | calculatedPointer=&portBFunctions.pinZero + portBitNumber;
42 | *calculatedPointer = userFunction;
43 | #endif
44 | portSnapshotB=*portInputRegister(portNumber);
45 | pcmsk=&PCMSK0;
46 | PCICR |= _BV(0);
47 | }
48 | #endif
49 | #ifndef EI_NOTPORTC
50 | if (portNumber==PC) {
51 | #ifndef NEEDFORSPEED
52 | calculatedPointer=&portCFunctions.pinZero + portBitNumber;
53 | *calculatedPointer = userFunction;
54 | #endif
55 | portSnapshotC=*portInputRegister(portNumber);
56 | pcmsk=&PCMSK1;
57 | PCICR |= _BV(1);
58 | }
59 | #endif
60 | #ifndef EI_NOTPORTD
61 | if (portNumber==PD) {
62 | #ifndef NEEDFORSPEED
63 | calculatedPointer=&portDFunctions.pinZero + portBitNumber;
64 | *calculatedPointer = userFunction;
65 | #endif
66 | portSnapshotD=*portInputRegister(portNumber);
67 | pcmsk=&PCMSK2;
68 | PCICR |= _BV(2);
69 | }
70 | #endif
71 | #endif // EI_SECTION_ASSIGNFUNCTIONSREGISTERS
72 |
73 | #ifdef EI_SECTION_DISABLEPINCHANGE
74 | #ifndef EI_NOTPORTB
75 | if (portNumber == PB) {
76 | PCMSK0 &= ~portMask;
77 | if (PCMSK0 == 0) { PCICR &= ~_BV(0); };
78 | risingPinsPORTB &= ~portMask;
79 | fallingPinsPORTB &= ~portMask;
80 | }
81 | #endif
82 | #ifndef EI_NOTPORTC
83 | if (portNumber == PC) {
84 | PCMSK1 &= ~portMask;
85 | if (PCMSK1 == 0) { PCICR &= ~_BV(1); };
86 | risingPinsPORTC &= ~portMask;
87 | fallingPinsPORTC &= ~portMask;
88 | }
89 | #endif
90 | #ifndef EI_NOTPORTD
91 | if (portNumber == PD) {
92 | PCMSK2 &= ~portMask;
93 | if (PCMSK2 == 0) { PCICR &= ~_BV(2); };
94 | risingPinsPORTD &= ~portMask;
95 | fallingPinsPORTD &= ~portMask;
96 | }
97 | #endif
98 | #endif // EI_SECTION_DISABLEPINCHANGE
99 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/utility/ei_PinChangeLeonardo.h:
--------------------------------------------------------------------------------
1 | #ifdef EI_SECTION_RISING
2 | #ifndef EI_NOTPORTB
3 | if (portNumber==PB) {
4 | risingPinsPORTB |= portMask;
5 | }
6 | #endif
7 | #endif // EI_SECTION_RISING
8 |
9 | #ifdef EI_SECTION_FALLING
10 | #ifndef EI_NOTPORTB
11 | if (portNumber==PB) {
12 | fallingPinsPORTB |= portMask;
13 | }
14 | #endif
15 | #endif // EI_SECTION_FALLING
16 |
17 | #if defined EI_SECTION_ASSIGNFUNCTIONSREGISTERS
18 | #ifndef EI_NOTPORTB
19 | if (portNumber==PB) {
20 | #ifndef NEEDFORSPEED
21 | calculatedPointer=&portBFunctions.pinZero + portBitNumber;
22 | *calculatedPointer = userFunction;
23 | #endif
24 | portSnapshotB=*portInputRegister(portNumber);
25 | pcmsk=&PCMSK0;
26 | PCICR |= _BV(0);
27 | }
28 | #endif
29 | #endif // EI_SECTION_ASSIGNFUNCTIONSREGISTERS
30 |
31 | #ifdef EI_SECTION_DISABLEPINCHANGE
32 | #ifndef EI_NOTPORTB
33 | if (portNumber == PB) {
34 | PCMSK0 &= ~portMask;
35 | if (PCMSK0 == 0) { PCICR &= ~_BV(0); };
36 | risingPinsPORTB &= ~portMask;
37 | fallingPinsPORTB &= ~portMask;
38 | }
39 | #endif
40 | #endif // EI_SECTION_DISABLEPINCHANGE
41 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/utility/ei_pindefs_speed.h:
--------------------------------------------------------------------------------
1 | #ifdef INTERRUPT_FLAG_PIN0
2 | volatile uint8_t INTERRUPT_FLAG_PIN0 = 0;
3 | #endif
4 | #ifdef INTERRUPT_FLAG_PIN1
5 | volatile uint8_t INTERRUPT_FLAG_PIN1 = 0;
6 | #endif
7 | #ifdef INTERRUPT_FLAG_PIN2
8 | volatile uint8_t INTERRUPT_FLAG_PIN2 = 0;
9 | #endif
10 | #ifdef INTERRUPT_FLAG_PIN3
11 | volatile uint8_t INTERRUPT_FLAG_PIN3 = 0;
12 | #endif
13 | #ifdef INTERRUPT_FLAG_PIN4
14 | volatile uint8_t INTERRUPT_FLAG_PIN4 = 0;
15 | #endif
16 | #ifdef INTERRUPT_FLAG_PIN5
17 | volatile uint8_t INTERRUPT_FLAG_PIN5 = 0;
18 | #endif
19 | #ifdef INTERRUPT_FLAG_PIN6
20 | volatile uint8_t INTERRUPT_FLAG_PIN6 = 0;
21 | #endif
22 | #ifdef INTERRUPT_FLAG_PIN7
23 | volatile uint8_t INTERRUPT_FLAG_PIN7 = 0;
24 | #endif
25 | #ifdef INTERRUPT_FLAG_PIN8
26 | volatile uint8_t INTERRUPT_FLAG_PIN8 = 0;
27 | #endif
28 | #ifdef INTERRUPT_FLAG_PIN9
29 | volatile uint8_t INTERRUPT_FLAG_PIN9 = 0;
30 | #endif
31 | #ifdef INTERRUPT_FLAG_PIN10
32 | volatile uint8_t INTERRUPT_FLAG_PIN10 = 0;
33 | #endif
34 | #ifdef INTERRUPT_FLAG_PIN11
35 | volatile uint8_t INTERRUPT_FLAG_PIN11 = 0;
36 | #endif
37 | #ifdef INTERRUPT_FLAG_PIN12
38 | volatile uint8_t INTERRUPT_FLAG_PIN12 = 0;
39 | #endif
40 | #ifdef INTERRUPT_FLAG_PIN13
41 | volatile uint8_t INTERRUPT_FLAG_PIN13 = 0;
42 | #endif
43 | #ifdef INTERRUPT_FLAG_PIN14
44 | volatile uint8_t INTERRUPT_FLAG_PIN14 = 0;
45 | #endif
46 | #ifdef INTERRUPT_FLAG_PIN15
47 | volatile uint8_t INTERRUPT_FLAG_PIN15 = 0;
48 | #endif
49 |
50 | #ifdef INTERRUPT_FLAG_PIN18
51 | volatile uint8_t INTERRUPT_FLAG_PIN18 = 0;
52 | #endif
53 | #ifdef INTERRUPT_FLAG_PIN19
54 | volatile uint8_t INTERRUPT_FLAG_PIN19 = 0;
55 | #endif
56 | #ifdef INTERRUPT_FLAG_PIN20
57 | volatile uint8_t INTERRUPT_FLAG_PIN20 = 0;
58 | #endif
59 | #ifdef INTERRUPT_FLAG_PIN21
60 | volatile uint8_t INTERRUPT_FLAG_PIN21 = 0;
61 | #endif
62 |
63 | #ifdef INTERRUPT_FLAG_PINA0
64 | volatile uint8_t INTERRUPT_FLAG_PINA0 = 0;
65 | #endif
66 | #ifdef INTERRUPT_FLAG_PINA1
67 | volatile uint8_t INTERRUPT_FLAG_PINA1 = 0;
68 | #endif
69 | #ifdef INTERRUPT_FLAG_PINA2
70 | volatile uint8_t INTERRUPT_FLAG_PINA2 = 0;
71 | #endif
72 | #ifdef INTERRUPT_FLAG_PINA3
73 | volatile uint8_t INTERRUPT_FLAG_PINA3 = 0;
74 | #endif
75 | #ifdef INTERRUPT_FLAG_PINA4
76 | volatile uint8_t INTERRUPT_FLAG_PINA4 = 0;
77 | #endif
78 | #ifdef INTERRUPT_FLAG_PINA5
79 | volatile uint8_t INTERRUPT_FLAG_PINA5 = 0;
80 | #endif
81 | #ifdef INTERRUPT_FLAG_PINA8
82 | volatile uint8_t INTERRUPT_FLAG_PINA8 = 0;
83 | #endif
84 | #ifdef INTERRUPT_FLAG_PINA9
85 | volatile uint8_t INTERRUPT_FLAG_PINA9 = 0;
86 | #endif
87 | #ifdef INTERRUPT_FLAG_PINA10
88 | volatile uint8_t INTERRUPT_FLAG_PINA10 = 0;
89 | #endif
90 | #ifdef INTERRUPT_FLAG_PINA11
91 | volatile uint8_t INTERRUPT_FLAG_PINA11 = 0;
92 | #endif
93 | #ifdef INTERRUPT_FLAG_PINA12
94 | volatile uint8_t INTERRUPT_FLAG_PINA12 = 0;
95 | #endif
96 | #ifdef INTERRUPT_FLAG_PINA13
97 | volatile uint8_t INTERRUPT_FLAG_PINA13 = 0;
98 | #endif
99 | #ifdef INTERRUPT_FLAG_PINA14
100 | volatile uint8_t INTERRUPT_FLAG_PINA14 = 0;
101 | #endif
102 | #ifdef INTERRUPT_FLAG_PINA15
103 | volatile uint8_t INTERRUPT_FLAG_PINA15 = 0;
104 | #endif
105 | #ifdef INTERRUPT_FLAG_PINSS
106 | volatile uint8_t INTERRUPT_FLAG_PINSS = 0;
107 | #endif
108 | #ifdef INTERRUPT_FLAG_PINSCK
109 | volatile uint8_t INTERRUPT_FLAG_PINSCK = 0;
110 | #endif
111 | #ifdef INTERRUPT_FLAG_PINMOSI
112 | volatile uint8_t INTERRUPT_FLAG_PINMOSI = 0;
113 | #endif
114 | #ifdef INTERRUPT_FLAG_PINMISO
115 | volatile uint8_t INTERRUPT_FLAG_PINMISO = 0;
116 | #endif
117 | #ifdef INTERRUPT_FLAG_PIN70
118 | volatile uint8_t INTERRUPT_FLAG_PIN70 = 0;
119 | #endif
120 | #ifdef INTERRUPT_FLAG_PIN71
121 | volatile uint8_t INTERRUPT_FLAG_PIN71 = 0;
122 | #endif
123 | #ifdef INTERRUPT_FLAG_PIN72
124 | volatile uint8_t INTERRUPT_FLAG_PIN72 = 0;
125 | #endif
126 | #ifdef INTERRUPT_FLAG_PIN73
127 | volatile uint8_t INTERRUPT_FLAG_PIN73 = 0;
128 | #endif
129 | #ifdef INTERRUPT_FLAG_PIN74
130 | volatile uint8_t INTERRUPT_FLAG_PIN74 = 0;
131 | #endif
132 | #ifdef INTERRUPT_FLAG_PIN75
133 | volatile uint8_t INTERRUPT_FLAG_PIN75 = 0;
134 | #endif
135 | #ifdef INTERRUPT_FLAG_PIN76
136 | volatile uint8_t INTERRUPT_FLAG_PIN76 = 0;
137 | #endif
138 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/utility/ei_porta_speed.h:
--------------------------------------------------------------------------------
1 | #if defined MIGHTY1284
2 | #ifdef INTERRUPT_FLAG_PIN24
3 | if (interruptMask & _BV(0)) INTERRUPT_FLAG_PIN24++;
4 | #endif
5 | #ifdef INTERRUPT_FLAG_PIN25
6 | if (interruptMask & _BV(1)) INTERRUPT_FLAG_PIN25++;
7 | #endif
8 | #ifdef INTERRUPT_FLAG_PIN26
9 | if (interruptMask & _BV(2)) INTERRUPT_FLAG_PIN26++;
10 | #endif
11 | #ifdef INTERRUPT_FLAG_PIN27
12 | if (interruptMask & _BV(3)) INTERRUPT_FLAG_PIN27++;
13 | #endif
14 | #ifdef INTERRUPT_FLAG_PIN28
15 | if (interruptMask & _BV(4)) INTERRUPT_FLAG_PIN28++;
16 | #endif
17 | #ifdef INTERRUPT_FLAG_PIN29
18 | if (interruptMask & _BV(5)) INTERRUPT_FLAG_PIN29++;
19 | #endif
20 | #ifdef INTERRUPT_FLAG_PIN30
21 | if (interruptMask & _BV(6)) INTERRUPT_FLAG_PIN30++;
22 | #endif
23 | #ifdef INTERRUPT_FLAG_PIN31
24 | if (interruptMask & _BV(7)) INTERRUPT_FLAG_PIN31++;
25 | #endif
26 | #endif
27 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/utility/ei_portb_speed.h:
--------------------------------------------------------------------------------
1 | #if defined MIGHTY1284
2 | #ifdef INTERRUPT_FLAG_PIN0
3 | if (interruptMask & _BV(0)) INTERRUPT_FLAG_PIN0++;
4 | #endif
5 | #ifdef INTERRUPT_FLAG_PIN1
6 | if (interruptMask & _BV(1)) INTERRUPT_FLAG_PIN1++;
7 | #endif
8 | #ifdef INTERRUPT_FLAG_PIN2
9 | if (interruptMask & _BV(2)) INTERRUPT_FLAG_PIN2++;
10 | #endif
11 | #ifdef INTERRUPT_FLAG_PIN3
12 | if (interruptMask & _BV(3)) INTERRUPT_FLAG_PIN3++;
13 | #endif
14 | #ifdef INTERRUPT_FLAG_PIN4
15 | if (interruptMask & _BV(4)) INTERRUPT_FLAG_PIN4++;
16 | #endif
17 | #ifdef INTERRUPT_FLAG_PIN5
18 | if (interruptMask & _BV(5)) INTERRUPT_FLAG_PIN5++;
19 | #endif
20 | #ifdef INTERRUPT_FLAG_PIN6
21 | if (interruptMask & _BV(6)) INTERRUPT_FLAG_PIN6++;
22 | #endif
23 | #ifdef INTERRUPT_FLAG_PIN7
24 | if (interruptMask & _BV(7)) INTERRUPT_FLAG_PIN7++;
25 | #endif
26 | #endif
27 |
28 | #if defined LEONARDO
29 | #ifdef INTERRUPT_FLAG_PINSS
30 | if (interruptMask & _BV(0)) INTERRUPT_FLAG_PINSS++;
31 | #endif
32 | #ifdef INTERRUPT_FLAG_PINSCK
33 | if (interruptMask & _BV(1)) INTERRUPT_FLAG_PINSCK++;
34 | #endif
35 | #ifdef INTERRUPT_FLAG_PINMOSI
36 | if (interruptMask & _BV(2)) INTERRUPT_FLAG_PINMOSI++;
37 | #endif
38 | #ifdef INTERRUPT_FLAG_PINMISO
39 | if (interruptMask & _BV(3)) INTERRUPT_FLAG_PINMISO++;
40 | #endif
41 | #ifdef INTERRUPT_FLAG_PIN8
42 | if (interruptMask & _BV(4)) INTERRUPT_FLAG_PIN8++;
43 | #endif
44 | #ifdef INTERRUPT_FLAG_PIN9
45 | if (interruptMask & _BV(5)) INTERRUPT_FLAG_PIN9++;
46 | #endif
47 | #ifdef INTERRUPT_FLAG_PIN10
48 | if (interruptMask & _BV(6)) INTERRUPT_FLAG_PIN10++;
49 | #endif
50 | #ifdef INTERRUPT_FLAG_PIN11
51 | if (interruptMask & _BV(7)) INTERRUPT_FLAG_PIN11++;
52 | #endif
53 | #endif
54 |
55 | #if defined ARDUINO_328
56 | #ifdef INTERRUPT_FLAG_PIN8
57 | if (interruptMask & _BV(0)) INTERRUPT_FLAG_PIN8++;
58 | #endif
59 | #ifdef INTERRUPT_FLAG_PIN9
60 | if (interruptMask & _BV(1)) INTERRUPT_FLAG_PIN9++;
61 | #endif
62 | #ifdef INTERRUPT_FLAG_PIN10
63 | if (interruptMask & _BV(2)) INTERRUPT_FLAG_PIN10++;
64 | #endif
65 | #ifdef INTERRUPT_FLAG_PIN11
66 | if (interruptMask & _BV(3)) INTERRUPT_FLAG_PIN11++;
67 | #endif
68 | #ifdef INTERRUPT_FLAG_PIN12
69 | if (interruptMask & _BV(4)) INTERRUPT_FLAG_PIN12++;
70 | #endif
71 | #ifdef INTERRUPT_FLAG_PIN13
72 | if (interruptMask & _BV(5)) INTERRUPT_FLAG_PIN13++;
73 | #endif
74 | #endif
75 |
76 | #if defined ARDUINO_MEGA
77 | #ifdef INTERRUPT_FLAG_PINSS
78 | if (interruptMask & _BV(0)) INTERRUPT_FLAG_PINSS++;
79 | #endif
80 | #ifdef INTERRUPT_FLAG_PINSCK
81 | if (interruptMask & _BV(1)) INTERRUPT_FLAG_PINSCK++;
82 | #endif
83 | #ifdef INTERRUPT_FLAG_PINMOSI
84 | if (interruptMask & _BV(2)) INTERRUPT_FLAG_PINMOSI++;
85 | #endif
86 | #ifdef INTERRUPT_FLAG_PINMISO
87 | if (interruptMask & _BV(3)) INTERRUPT_FLAG_PINMISO++;
88 | #endif
89 | #ifdef INTERRUPT_FLAG_PIN10
90 | if (interruptMask & _BV(4)) INTERRUPT_FLAG_PIN10++;
91 | #endif
92 | #ifdef INTERRUPT_FLAG_PIN11
93 | if (interruptMask & _BV(5)) INTERRUPT_FLAG_PIN11++;
94 | #endif
95 | #ifdef INTERRUPT_FLAG_PIN12
96 | if (interruptMask & _BV(6)) INTERRUPT_FLAG_PIN12++;
97 | #endif
98 | #ifdef INTERRUPT_FLAG_PIN13
99 | if (interruptMask & _BV(7)) INTERRUPT_FLAG_PIN13++;
100 | #endif
101 | #endif
102 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/utility/ei_portc_speed.h:
--------------------------------------------------------------------------------
1 | #if defined MIGHTY1284
2 | #if defined INTERRUPT_FLAG_PIN16
3 | if (interruptMask & _BV(0)) INTERRUPT_FLAG_PIN16++;
4 | #endif
5 | #if defined INTERRUPT_FLAG_PIN17
6 | if (interruptMask & _BV(1)) INTERRUPT_FLAG_PIN17++;
7 | #endif
8 | #if defined INTERRUPT_FLAG_PIN18
9 | if (interruptMask & _BV(2)) INTERRUPT_FLAG_PIN18++;
10 | #endif
11 | #if defined INTERRUPT_FLAG_PIN19
12 | if (interruptMask & _BV(3)) INTERRUPT_FLAG_PIN19++;
13 | #endif
14 | #if defined INTERRUPT_FLAG_PIN20
15 | if (interruptMask & _BV(4)) INTERRUPT_FLAG_PIN20++;
16 | #endif
17 | #if defined INTERRUPT_FLAG_PIN21
18 | if (interruptMask & _BV(5)) INTERRUPT_FLAG_PIN21++;
19 | #endif
20 | #if defined INTERRUPT_FLAG_PIN22
21 | if (interruptMask & _BV(5)) INTERRUPT_FLAG_PIN22++;
22 | #endif
23 | #if defined INTERRUPT_FLAG_PIN23
24 | if (interruptMask & _BV(5)) INTERRUPT_FLAG_PIN23++;
25 | #endif
26 | #endif
27 |
28 | #if defined ARDUINO_328
29 | #if defined INTERRUPT_FLAG_PINA0
30 | if (interruptMask & _BV(0)) INTERRUPT_FLAG_PINA0++;
31 | #endif
32 | #if defined INTERRUPT_FLAG_PINA1
33 | if (interruptMask & _BV(1)) INTERRUPT_FLAG_PINA1++;
34 | #endif
35 | #if defined INTERRUPT_FLAG_PINA2
36 | if (interruptMask & _BV(2)) INTERRUPT_FLAG_PINA2++;
37 | #endif
38 | #if defined INTERRUPT_FLAG_PINA3
39 | if (interruptMask & _BV(3)) INTERRUPT_FLAG_PINA3++;
40 | #endif
41 | #if defined INTERRUPT_FLAG_PINA4
42 | if (interruptMask & _BV(4)) INTERRUPT_FLAG_PINA4++;
43 | #endif
44 | #if defined INTERRUPT_FLAG_PINA5
45 | if (interruptMask & _BV(5)) INTERRUPT_FLAG_PINA5++;
46 | #endif
47 | #endif
48 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/utility/ei_portd_speed.h:
--------------------------------------------------------------------------------
1 | #if defined MIGHTY1284
2 | #if defined INTERRUPT_FLAG_PIN8
3 | if (interruptMask & _BV(0)) INTERRUPT_FLAG_PIN8++;
4 | #endif
5 | #if defined INTERRUPT_FLAG_PIN9
6 | if (interruptMask & _BV(1)) INTERRUPT_FLAG_PIN9++;
7 | #endif
8 | #if defined INTERRUPT_FLAG_PIN10
9 | if (interruptMask & _BV(2)) INTERRUPT_FLAG_PIN10++;
10 | #endif
11 | #if defined INTERRUPT_FLAG_PIN11
12 | if (interruptMask & _BV(3)) INTERRUPT_FLAG_PIN11++;
13 | #endif
14 | #if defined INTERRUPT_FLAG_PIN12
15 | if (interruptMask & _BV(4)) INTERRUPT_FLAG_PIN12++;
16 | #endif
17 | #if defined INTERRUPT_FLAG_PIN13
18 | if (interruptMask & _BV(5)) INTERRUPT_FLAG_PIN13++;
19 | #endif
20 | #if defined INTERRUPT_FLAG_PIN14
21 | if (interruptMask & _BV(6)) INTERRUPT_FLAG_PIN14++;
22 | #endif
23 | #if defined INTERRUPT_FLAG_PIN15
24 | if (interruptMask & _BV(7)) INTERRUPT_FLAG_PIN15++;
25 | #endif
26 | #endif
27 |
28 | #if defined ARDUINO_328
29 | #if defined INTERRUPT_FLAG_PIN0
30 | if (interruptMask & _BV(0)) INTERRUPT_FLAG_PIN0++;
31 | #endif
32 | #if defined INTERRUPT_FLAG_PIN1
33 | if (interruptMask & _BV(1)) INTERRUPT_FLAG_PIN1++;
34 | #endif
35 | #if defined INTERRUPT_FLAG_PIN2
36 | if (interruptMask & _BV(2)) INTERRUPT_FLAG_PIN2++;
37 | #endif
38 | #if defined INTERRUPT_FLAG_PIN3
39 | if (interruptMask & _BV(3)) INTERRUPT_FLAG_PIN3++;
40 | #endif
41 | #if defined INTERRUPT_FLAG_PIN4
42 | if (interruptMask & _BV(4)) INTERRUPT_FLAG_PIN4++;
43 | #endif
44 | #if defined INTERRUPT_FLAG_PIN5
45 | if (interruptMask & _BV(5)) INTERRUPT_FLAG_PIN5++;
46 | #endif
47 | #if defined INTERRUPT_FLAG_PIN6
48 | if (interruptMask & _BV(6)) INTERRUPT_FLAG_PIN6++;
49 | #endif
50 | #if defined INTERRUPT_FLAG_PIN7
51 | if (interruptMask & _BV(7)) INTERRUPT_FLAG_PIN7++;
52 | #endif
53 | #endif
54 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/utility/ei_portj_speed.h:
--------------------------------------------------------------------------------
1 | #if defined ARDUINO_MEGA
2 | #if defined INTERRUPT_FLAG_PIN15
3 | if (interruptMask & _BV(0)) INTERRUPT_FLAG_PIN15++;
4 | #endif
5 | #if defined INTERRUPT_FLAG_PIN14
6 | if (interruptMask & _BV(1)) INTERRUPT_FLAG_PIN14++;
7 | #endif
8 | #if defined INTERRUPT_FLAG_PIN70
9 | if (interruptMask & _BV(2)) INTERRUPT_FLAG_PIN70++;
10 | #endif
11 | #if defined INTERRUPT_FLAG_PIN71
12 | if (interruptMask & _BV(3)) INTERRUPT_FLAG_PIN71++;
13 | #endif
14 | #if defined INTERRUPT_FLAG_PIN72
15 | if (interruptMask & _BV(4)) INTERRUPT_FLAG_PIN72++;
16 | #endif
17 | #if defined INTERRUPT_FLAG_PIN73
18 | if (interruptMask & _BV(5)) INTERRUPT_FLAG_PIN73++;
19 | #endif
20 | #if defined INTERRUPT_FLAG_PIN74
21 | if (interruptMask & _BV(6)) INTERRUPT_FLAG_PIN74++;
22 | #endif
23 | #endif
24 | // NOTE: 75 and 76 are "fake" External interrupt pins.
25 |
--------------------------------------------------------------------------------
/libraries/EnableInterrupt/utility/ei_portk_speed.h:
--------------------------------------------------------------------------------
1 | #if defined ARDUINO_MEGA
2 | #if defined INTERRUPT_FLAG_PINA8
3 | if (interruptMask & _BV(0)) INTERRUPT_FLAG_PINA8++;
4 | #endif
5 | #if defined INTERRUPT_FLAG_PINA9
6 | if (interruptMask & _BV(1)) INTERRUPT_FLAG_PINA9++;
7 | #endif
8 | #if defined INTERRUPT_FLAG_PINA10
9 | if (interruptMask & _BV(2)) INTERRUPT_FLAG_PINA10++;
10 | #endif
11 | #if defined INTERRUPT_FLAG_PINA11
12 | if (interruptMask & _BV(3)) INTERRUPT_FLAG_PINA11++;
13 | #endif
14 | #if defined INTERRUPT_FLAG_PINA12
15 | if (interruptMask & _BV(4)) INTERRUPT_FLAG_PINA12++;
16 | #endif
17 | #if defined INTERRUPT_FLAG_PINA13
18 | if (interruptMask & _BV(5)) INTERRUPT_FLAG_PINA13++;
19 | #endif
20 | #if defined INTERRUPT_FLAG_PINA14
21 | if (interruptMask & _BV(6)) INTERRUPT_FLAG_PINA14++;
22 | #endif
23 | #if defined INTERRUPT_FLAG_PINA15
24 | if (interruptMask & _BV(7)) INTERRUPT_FLAG_PINA15++;
25 | #endif
26 | #endif
27 |
--------------------------------------------------------------------------------
/libraries/I2Cdev/keywords.txt:
--------------------------------------------------------------------------------
1 | #######################################
2 | # Syntax Coloring Map For I2Cdev
3 | #######################################
4 |
5 | #######################################
6 | # Datatypes (KEYWORD1)
7 | #######################################
8 | I2Cdev KEYWORD1
9 |
10 | #######################################
11 | # Methods and Functions (KEYWORD2)
12 | #######################################
13 |
14 | readBit KEYWORD2
15 | readBitW KEYWORD2
16 | readBits KEYWORD2
17 | readBitsW KEYWORD2
18 | readByte KEYWORD2
19 | readBytes KEYWORD2
20 | readWord KEYWORD2
21 | readWords KEYWORD2
22 | writeBit KEYWORD2
23 | writeBitW KEYWORD2
24 | writeBits KEYWORD2
25 | writeBitsW KEYWORD2
26 | writeByte KEYWORD2
27 | writeBytes KEYWORD2
28 | writeWord KEYWORD2
29 | writeWords KEYWORD2
30 |
31 | #######################################
32 | # Instances (KEYWORD2)
33 | #######################################
34 |
35 | #######################################
36 | # Constants (LITERAL1)
37 | #######################################
38 |
39 |
--------------------------------------------------------------------------------
/libraries/I2Cdev/library.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "I2Cdevlib-Core",
3 | "keywords": "i2cdevlib, i2c",
4 | "description": "The I2C Device Library (I2Cdevlib) is a collection of uniform and well-documented classes to provide simple and intuitive interfaces to I2C devices.",
5 | "include": "Arduino/I2Cdev",
6 | "repository":
7 | {
8 | "type": "git",
9 | "url": "https://github.com/jrowberg/i2cdevlib.git"
10 | },
11 | "frameworks": "arduino",
12 | "platforms": "atmelavr"
13 | }
14 |
--------------------------------------------------------------------------------
/libraries/LedMatrix/LedMatrix.cpp:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Zowi LED Matrix Library
3 | *
4 | * @version 20150710
5 | * @author Raul de Pablos Martin
6 | * José Alberca Pita-Romero (Mouth's definitions)
7 | ******************************************************************************/
8 |
9 | #include "LedMatrix.h"
10 |
11 | #if defined(ARDUINO) && ARDUINO >= 100
12 | #include "Arduino.h"
13 | #else
14 | #include "WProgram.h"
15 | #endif
16 |
17 | LedMatrix::LedMatrix(char ser_pin, char clk_pin, char rck_pin) {
18 | memory = 0x00000000;
19 | SER = ser_pin;
20 | CLK = clk_pin;
21 | RCK = rck_pin;
22 | pinMode(SER, OUTPUT);
23 | pinMode(CLK, OUTPUT);
24 | pinMode(RCK, OUTPUT);
25 | digitalWrite(SER, LOW);
26 | digitalWrite(CLK, LOW);
27 | digitalWrite(RCK, LOW);
28 | sendMemory();
29 | }
30 |
31 | void LedMatrix::writeFull(unsigned long value) {
32 | memory = value;
33 | sendMemory();
34 | }
35 |
36 | unsigned long LedMatrix::readFull(void) {
37 | return memory;
38 | }
39 |
40 | void LedMatrix::setLed(char row, char column) {
41 | if(row >= 1 && row <= ROWS && column >= 1 && column <= COLUMNS) {
42 | memory |= (1L << (MATRIX_LENGTH - (row-1)*COLUMNS - (column)));
43 | sendMemory();
44 | }
45 | }
46 |
47 | void LedMatrix::unsetLed(char row, char column) {
48 | if(row >= 1 && row <= ROWS && column >= 1 && column <= COLUMNS) {
49 | memory &= ~(1L << (MATRIX_LENGTH - (row-1)*COLUMNS - (column)));
50 | sendMemory();
51 | }
52 | }
53 |
54 | void LedMatrix::clearMatrix(void) {
55 | memory = 0x00000000;
56 | sendMemory();
57 | }
58 |
59 | void LedMatrix::setEntireMatrix(void) {
60 | memory = 0x3FFFFFFF;
61 | sendMemory();
62 | }
63 |
64 | void LedMatrix::sendMemory(void) {
65 | int i;
66 |
67 | for(i = 0; i < MATRIX_LENGTH; i++) {
68 | digitalWrite(SER, 1L & (memory >> i));
69 | // ## adjust this delay to match with 74HC595 timing
70 | asm volatile ("nop");
71 | asm volatile ("nop");
72 | asm volatile ("nop");
73 | digitalWrite(CLK, 1);
74 | // ## adjust this delay to match with 74HC595 timing
75 | asm volatile ("nop");
76 | asm volatile ("nop");
77 | asm volatile ("nop");
78 | digitalWrite(CLK, 0);
79 | }
80 |
81 | digitalWrite(RCK, 1);
82 | // ## adjust this delay to match with 74HC595 timing
83 | asm volatile ("nop");
84 | asm volatile ("nop");
85 | asm volatile ("nop");
86 | digitalWrite(RCK, 0);
87 | }
88 |
89 |
--------------------------------------------------------------------------------
/libraries/LedMatrix/LedMatrix.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Zowi LED Matrix Library
3 | *
4 | * @version 20150710
5 | * @author Raul de Pablos Martin
6 | * José Alberca Pita-Romero (Mouth's definitions)
7 | *
8 | ******************************************************************************/
9 | #ifndef __LEDMATRIX_H__
10 | #define __LEDMATRIX_H__
11 |
12 | #if defined(ARDUINO) && ARDUINO >= 100
13 | #include "Arduino.h"
14 | #else
15 | #include "WProgram.h"
16 | #include "pins_arduino.h"
17 | #endif
18 |
19 | ////////////////////////////
20 | // Definitions //
21 | ////////////////////////////
22 | #define ROWS 5
23 | #define COLUMNS 6
24 | #define MATRIX_LENGTH ROWS*COLUMNS
25 |
26 |
27 |
28 |
29 |
30 | class LedMatrix
31 | {
32 | public:
33 | ////////////////////////////
34 | // Enumerations //
35 | ////////////////////////////
36 |
37 | ////////////////////////////
38 | // Variables //
39 | ////////////////////////////
40 |
41 | ////////////////////////////
42 | // Functions //
43 | ////////////////////////////
44 | // LedMatrix -- LedMatrix class constructor
45 | LedMatrix(char ser_pin=11, char clk_pin=13, char rck_pin=12);
46 |
47 | // writeFull
48 | void writeFull(unsigned long value);
49 |
50 | // readFull
51 | unsigned long readFull(void);
52 |
53 | // setLed
54 | void setLed(char row, char column);
55 |
56 | // unsetLed
57 | void unsetLed(char row, char column);
58 |
59 | // readLed
60 | bool readLed(char row, char column);
61 |
62 | // clearMatrix
63 | void clearMatrix(void);
64 |
65 | // setEntireMatrix
66 | void setEntireMatrix(void);
67 |
68 |
69 |
70 | private:
71 | ////////////////////////////
72 | // Enumerations //
73 | ////////////////////////////
74 |
75 |
76 | ////////////////////////////
77 | // Variables //
78 | ////////////////////////////
79 | unsigned long memory;
80 | char SER;
81 | char CLK;
82 | char RCK;
83 |
84 |
85 | ////////////////////////////
86 | // Functions //
87 | ////////////////////////////
88 | void sendMemory(void);
89 |
90 |
91 | };
92 |
93 | #endif // LEDMATRIX_H //
94 |
--------------------------------------------------------------------------------
/libraries/LedMatrix/LedMatrix.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smartmecard/arduino-smart-robot-car/c5a0554a11c4e41a61c79af503f3163ffec319cb/libraries/LedMatrix/LedMatrix.zip
--------------------------------------------------------------------------------
/libraries/LedMatrix/LedMatrix_Code/LedMatrix_Code.ino:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | LedMatrix ledmatrix(11, 13, 12);
4 |
5 | void setup() {
6 | Serial.begin(115200);
7 |
8 | ledmatrix.writeFull(0x3FFFFFFF);
9 | delay(1000);
10 |
11 | ledmatrix.clearMatrix();
12 | delay(1000);
13 |
14 | }
15 |
16 | void loop() {
17 | ledmatrix.setLed(1, 1);
18 | ledmatrix.setLed(2, 2);
19 | ledmatrix.setLed(3, 3);
20 | ledmatrix.setLed(4, 4);
21 | ledmatrix.setLed(5, 5);
22 |
23 |
24 | printLong(ledmatrix.readFull());
25 | }
26 |
27 | void printLong(unsigned long toprint) {
28 | unsigned long i;
29 | for(i = 0; i < 32; i++) {
30 | if(toprint & (1L << (31 - i))) Serial.print("1");
31 | else Serial.print("0");
32 | }
33 | Serial.println("");
34 | }
35 |
--------------------------------------------------------------------------------
/libraries/MAX7219-MAX7221.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smartmecard/arduino-smart-robot-car/c5a0554a11c4e41a61c79af503f3163ffec319cb/libraries/MAX7219-MAX7221.pdf
--------------------------------------------------------------------------------
/libraries/MPU6050/library.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "I2Cdevlib-MPU6050",
3 | "keywords": "gyroscope, accelerometer, sensor, i2cdevlib, i2c",
4 | "description": "The MPU6050 combines a 3-axis gyroscope and a 3-axis accelerometer on the same silicon die together with an onboard Digital Motion Processor(DMP) which processes complex 6-axis MotionFusion algorithms",
5 | "include": "Arduino/MPU6050",
6 | "repository":
7 | {
8 | "type": "git",
9 | "url": "https://github.com/jrowberg/i2cdevlib.git"
10 | },
11 | "dependencies":
12 | {
13 | "name": "I2Cdevlib-Core",
14 | "frameworks": "arduino"
15 | },
16 | "frameworks": "arduino",
17 | "platforms": "atmelavr"
18 | }
19 |
--------------------------------------------------------------------------------
/libraries/MaxMatrix/MaxMatrix.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * MaxMatrix
3 | * Version 1.0 Feb 2013
4 | * Copyright 2013 Oscar Kin-Chung Au
5 | */
6 |
7 |
8 | #include "Arduino.h"
9 | #include "MaxMatrix.h"
10 |
11 | MaxMatrix::MaxMatrix(byte _data, byte _load, byte _clock, byte _num)
12 | {
13 | data = _data;
14 | load = _load;
15 | clock = _clock;
16 | num = _num;
17 | for (int i=0; i<80; i++)
18 | buffer[i] = 0;
19 | }
20 |
21 | void MaxMatrix::init()
22 | {
23 | pinMode(data, OUTPUT);
24 | pinMode(clock, OUTPUT);
25 | pinMode(load, OUTPUT);
26 | digitalWrite(clock, HIGH);
27 |
28 | setCommand(max7219_reg_scanLimit, 0x07);
29 | setCommand(max7219_reg_decodeMode, 0x00); // using an led matrix (not digits)
30 | setCommand(max7219_reg_shutdown, 0x01); // not in shutdown mode
31 | setCommand(max7219_reg_displayTest, 0x00); // no display test
32 |
33 | // empty registers, turn all LEDs off
34 | clearMatrix();
35 |
36 | setIntensity(0x0f); // the first 0x0f is the value you can set
37 | }
38 |
39 | void MaxMatrix::setIntensity(byte intensity)
40 | {
41 | setCommand(max7219_reg_intensity, intensity);
42 | }
43 |
44 | void MaxMatrix::clearMatrix()
45 | {
46 | for (int i=0; i<8; i++)
47 | setColumnAll(i,0);
48 |
49 | for (int i=0; i<80; i++)
50 | buffer[i] = 0;
51 | }
52 |
53 | void MaxMatrix::setCommand(byte command, byte value)
54 | {
55 | digitalWrite(load, LOW);
56 | for (int i=0; i=0 && c<80)
137 | setColumn(c, sprite[i+2]);
138 | }
139 | else
140 | for (int i=0; i=0 && c<80 && r>=0 && r<8)
146 | setDot(c, r, bitRead(sprite[i+2], j));
147 | }
148 | }
149 |
150 | void MaxMatrix::reload()
151 | {
152 | for (int i=0; i<8; i++)
153 | {
154 | int col = i;
155 | digitalWrite(load, LOW);
156 | for (int j=0; j0; i--)
185 | buffer[i] = buffer[i-1];
186 | if (rotate) buffer[0] = old;
187 | else if (fill_zero) buffer[0] = 0;
188 |
189 | reload();
190 | }
191 |
192 | void MaxMatrix::shiftUp(bool rotate)
193 | {
194 | for (int i=0; i>= 1;
198 | if (rotate) bitWrite(buffer[i], 7, b);
199 | }
200 | reload();
201 | }
202 |
203 | void MaxMatrix::shiftDown(bool rotate)
204 | {
205 | for (int i=0; i> r*6+c)));
219 | }
220 | }
221 | }
222 |
223 |
--------------------------------------------------------------------------------
/libraries/MaxMatrix/MaxMatrix.h:
--------------------------------------------------------------------------------
1 | /*
2 | * MaxMatrix
3 | * Version 1.0 Feb 2013
4 | * Copyright 2013 Oscar Kin-Chung Au
5 | */
6 |
7 | #ifndef _MaxMatrix_H_
8 | #define _MaxMatrix_H_
9 |
10 | #include "Arduino.h"
11 |
12 | #define max7219_reg_noop 0x00
13 | #define max7219_reg_digit0 0x01
14 | #define max7219_reg_digit1 0x02
15 | #define max7219_reg_digit2 0x03
16 | #define max7219_reg_digit3 0x04
17 | #define max7219_reg_digit4 0x05
18 | #define max7219_reg_digit5 0x06
19 | #define max7219_reg_digit6 0x07
20 | #define max7219_reg_digit7 0x08
21 | #define max7219_reg_decodeMode 0x09
22 | #define max7219_reg_intensity 0x0a
23 | #define max7219_reg_scanLimit 0x0b
24 | #define max7219_reg_shutdown 0x0c
25 | #define max7219_reg_displayTest 0x0f
26 |
27 | class MaxMatrix
28 | {
29 | private:
30 | byte data;
31 | byte load;
32 | byte clock;
33 | byte num;
34 | byte buffer[80];
35 |
36 | void reload();
37 |
38 | public:
39 | MaxMatrix(byte data, byte load, byte clock, byte num);
40 |
41 | void init();
42 | void clearMatrix();
43 | void setCommand(byte command, byte value);
44 | void setIntensity(byte intensity);
45 | void setColumn(byte col, byte value);
46 | void setColumnAll(byte col, byte value);
47 | void setDot(byte col, byte row, byte value);
48 | //void writeSprite(int x, int y, const byte* sprite);
49 |
50 | //void shiftLeft(bool rotate = false, bool fill_zero = true);
51 | //void shiftRight(bool rotate = false, bool fill_zero = true);
52 | //void shiftUp(bool rotate = false);
53 | //void shiftDown(bool rotate = false);
54 | void writeFull(unsigned long value);
55 | };
56 |
57 | #endif
58 |
--------------------------------------------------------------------------------
/libraries/MaxMatrix/MaxMatrix.ino:
--------------------------------------------------------------------------------
1 | #include "MaxMatrix.h"
2 | #define NumMatrix 1 // Cuantas matrices vamos a usar
3 | byte Buf7219[7]; // "width,height,data[5]" single character buffer.
4 |
5 | MaxMatrix lc=MaxMatrix(12,10,11, NumMatrix); // Creamos una instancia de LedControl
6 | #define zero_code 0b00001100010010010010010010001100
7 | #define one_code 0b00000100001100000100000100001110
8 | #define two_code 0b00001100010010000100001000011110
9 | #define three_code 0b00001100010010000100010010001100
10 | #define smile_code 0b00000000100001010010001100000000
11 |
12 | void setup()
13 | {
14 | for (int i=0; i< NumMatrix ; i++)
15 | {
16 | lc.init();
17 | lc.setIntensity(1); // Poner el brillo a un valor intermedio
18 | // lc.clearDisplay(i); // Y borrar todo
19 | }
20 | for (int i=0;i<8;i++){
21 | lc.setColumn(i,B11111111);}
22 | delay(100);
23 | // lc.clear();
24 | }
25 |
26 | void loop()
27 | {
28 |
29 | lc.writeFull(smile_code);
30 | delay(1000);
31 | lc.writeFull(three_code);
32 | delay(1000);
33 | lc.writeFull(two_code);
34 | delay(1000);
35 | lc.writeFull(one_code);
36 | delay(1000);
37 | lc.writeFull(zero_code);
38 | delay(1000);
39 | }
40 |
--------------------------------------------------------------------------------
/libraries/MsTimer2/MsTimer2.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | MsTimer2.h - Using timer2 with 1ms resolution
3 | Javier Valencia
4 |
5 | History:
6 | 29/May/09 - V0.5 added support for Atmega1280 (thanks to Manuel Negri)
7 | 19/Mar/09 - V0.4 added support for ATmega328P (thanks to Jerome Despatis)
8 | 11/Jun/08 - V0.3
9 | changes to allow working with different CPU frequencies
10 | added support for ATMega128 (using timer2)
11 | compatible with ATMega48/88/168/8
12 | 10/May/08 - V0.2 added some security tests and volatile keywords
13 | 9/May/08 - V0.1 released working on ATMEGA168 only
14 |
15 |
16 | This library is free software; you can redistribute it and/or
17 | modify it under the terms of the GNU Lesser General Public
18 | License as published by the Free Software Foundation; either
19 | version 2.1 of the License, or (at your option) any later version.
20 |
21 | This library is distributed in the hope that it will be useful,
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 | Lesser General Public License for more details.
25 |
26 | You should have received a copy of the GNU Lesser General Public
27 | License along with this library; if not, write to the Free Software
28 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 | */
30 |
31 | #include
32 |
33 | unsigned long MsTimer2::msecs;
34 | void (*MsTimer2::func)();
35 | volatile unsigned long MsTimer2::count;
36 | volatile char MsTimer2::overflowing;
37 | volatile unsigned int MsTimer2::tcnt2;
38 |
39 | void MsTimer2::set(unsigned long ms, void (*f)()) {
40 | float prescaler = 0.0;
41 |
42 | #if defined (__AVR_ATmega168__) || defined (__AVR_ATmega48__) || defined (__AVR_ATmega88__) || defined (__AVR_ATmega328P__) || (__AVR_ATmega1280__)
43 | TIMSK2 &= ~(1<= 1000000UL) && (F_CPU <= 16000000UL)) { // prescaler set to 64
50 | TCCR2B |= (1< 16Mhz, prescaler set to 128
58 | TCCR2B |= ((1<= 1000000UL) && (F_CPU <= 16000000UL)) { // prescaler set to 64
69 | TCCR2 |= (1< 16Mhz, prescaler set to 128
77 | TCCR2 |= ((1<= 1000000UL) && (F_CPU <= 16000000UL)) { // prescaler set to 64
87 | TCCR2 |= ((1< 16Mhz, prescaler set to 256
95 | TCCR2 |= (1<= msecs && !overflowing) {
140 | overflowing = 1;
141 | count = 0;
142 | (*func)();
143 | overflowing = 0;
144 | }
145 | }
146 |
147 | ISR(TIMER2_OVF_vect) {
148 | #if defined (__AVR_ATmega168__) || defined (__AVR_ATmega48__) || defined (__AVR_ATmega88__) || defined (__AVR_ATmega328P__) || (__AVR_ATmega1280__)
149 | TCNT2 = MsTimer2::tcnt2;
150 | #elif defined (__AVR_ATmega128__)
151 | TCNT2 = MsTimer2::tcnt2;
152 | #elif defined (__AVR_ATmega8__)
153 | TCNT2 = MsTimer2::tcnt2;
154 | #endif
155 | MsTimer2::_overflow();
156 | }
157 |
158 |
--------------------------------------------------------------------------------
/libraries/MsTimer2/MsTimer2.h:
--------------------------------------------------------------------------------
1 | #ifndef MsTimer2_h
2 | #define MsTimer2_h
3 |
4 | #include
5 |
6 | namespace MsTimer2 {
7 | extern unsigned long msecs;
8 | extern void (*func)();
9 | extern volatile unsigned long count;
10 | extern volatile char overflowing;
11 | extern volatile unsigned int tcnt2;
12 |
13 | void set(unsigned long ms, void (*f)());
14 | void start();
15 | void stop();
16 | void _overflow();
17 | }
18 |
19 | #endif
20 |
--------------------------------------------------------------------------------
/libraries/MsTimer2/examples/FlashLed/FlashLed.pde:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | // Switch on LED on pin 13 each second
4 |
5 |
6 | void flash() {
7 | static boolean output = HIGH;
8 |
9 | digitalWrite(13, output);
10 | output = !output;
11 | }
12 |
13 | void setup() {
14 | pinMode(13, OUTPUT);
15 |
16 | MsTimer2::set(500, flash); // 500ms period
17 | MsTimer2::start();
18 | }
19 |
20 | void loop() {
21 | }
22 |
--------------------------------------------------------------------------------
/libraries/NewPing/NewPing.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smartmecard/arduino-smart-robot-car/c5a0554a11c4e41a61c79af503f3163ffec319cb/libraries/NewPing/NewPing.h
--------------------------------------------------------------------------------
/libraries/NewPing/examples/NewPing15Sensors/NewPing15Sensors.pde:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------------
2 | // This example code was used to successfully communicate with 15 ultrasonic sensors. You can adjust
3 | // the number of sensors in your project by changing SONAR_NUM and the number of NewPing objects in the
4 | // "sonar" array. You also need to change the pins for each sensor for the NewPing objects. Each sensor
5 | // is pinged at 33ms intervals. So, one cycle of all sensors takes 495ms (33 * 15 = 495ms). The results
6 | // are sent to the "oneSensorCycle" function which currently just displays the distance data. Your project
7 | // would normally process the sensor results in this function (for example, decide if a robot needs to
8 | // turn and call the turn function). Keep in mind this example is event-driven. Your complete sketch needs
9 | // to be written so there's no "delay" commands and the loop() cycles at faster than a 33ms rate. If other
10 | // processes take longer than 33ms, you'll need to increase PING_INTERVAL so it doesn't get behind.
11 | // ---------------------------------------------------------------------------
12 | #include
13 |
14 | #define SONAR_NUM 15 // Number of sensors.
15 | #define MAX_DISTANCE 200 // Maximum distance (in cm) to ping.
16 | #define PING_INTERVAL 33 // Milliseconds between sensor pings (29ms is about the min to avoid cross-sensor echo).
17 |
18 | unsigned long pingTimer[SONAR_NUM]; // Holds the times when the next ping should happen for each sensor.
19 | unsigned int cm[SONAR_NUM]; // Where the ping distances are stored.
20 | uint8_t currentSensor = 0; // Keeps track of which sensor is active.
21 |
22 | NewPing sonar[SONAR_NUM] = { // Sensor object array.
23 | NewPing(41, 42, MAX_DISTANCE), // Each sensor's trigger pin, echo pin, and max distance to ping.
24 | NewPing(43, 44, MAX_DISTANCE),
25 | NewPing(45, 20, MAX_DISTANCE),
26 | NewPing(21, 22, MAX_DISTANCE),
27 | NewPing(23, 24, MAX_DISTANCE),
28 | NewPing(25, 26, MAX_DISTANCE),
29 | NewPing(27, 28, MAX_DISTANCE),
30 | NewPing(29, 30, MAX_DISTANCE),
31 | NewPing(31, 32, MAX_DISTANCE),
32 | NewPing(34, 33, MAX_DISTANCE),
33 | NewPing(35, 36, MAX_DISTANCE),
34 | NewPing(37, 38, MAX_DISTANCE),
35 | NewPing(39, 40, MAX_DISTANCE),
36 | NewPing(50, 51, MAX_DISTANCE),
37 | NewPing(52, 53, MAX_DISTANCE)
38 | };
39 |
40 | void setup() {
41 | Serial.begin(115200);
42 | pingTimer[0] = millis() + 75; // First ping starts at 75ms, gives time for the Arduino to chill before starting.
43 | for (uint8_t i = 1; i < SONAR_NUM; i++) // Set the starting time for each sensor.
44 | pingTimer[i] = pingTimer[i - 1] + PING_INTERVAL;
45 | }
46 |
47 | void loop() {
48 | for (uint8_t i = 0; i < SONAR_NUM; i++) { // Loop through all the sensors.
49 | if (millis() >= pingTimer[i]) { // Is it this sensor's time to ping?
50 | pingTimer[i] += PING_INTERVAL * SONAR_NUM; // Set next time this sensor will be pinged.
51 | if (i == 0 && currentSensor == SONAR_NUM - 1) oneSensorCycle(); // Sensor ping cycle complete, do something with the results.
52 | sonar[currentSensor].timer_stop(); // Make sure previous timer is canceled before starting a new ping (insurance).
53 | currentSensor = i; // Sensor being accessed.
54 | cm[currentSensor] = 0; // Make distance zero in case there's no ping echo for this sensor.
55 | sonar[currentSensor].ping_timer(echoCheck); // Do the ping (processing continues, interrupt will call echoCheck to look for echo).
56 | }
57 | }
58 | // Other code that *DOESN'T* analyze ping results can go here.
59 | }
60 |
61 | void echoCheck() { // If ping received, set the sensor distance to array.
62 | if (sonar[currentSensor].check_timer())
63 | cm[currentSensor] = sonar[currentSensor].ping_result / US_ROUNDTRIP_CM;
64 | }
65 |
66 | void oneSensorCycle() { // Sensor ping cycle complete, do something with the results.
67 | // The following code would be replaced with your code that does something with the ping results.
68 | for (uint8_t i = 0; i < SONAR_NUM; i++) {
69 | Serial.print(i);
70 | Serial.print("=");
71 | Serial.print(cm[i]);
72 | Serial.print("cm ");
73 | }
74 | Serial.println();
75 | }
--------------------------------------------------------------------------------
/libraries/NewPing/examples/NewPingEventTimer/NewPingEventTimer.pde:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------------
2 | // This example shows how to use NewPing's ping_timer method which uses the Timer2 interrupt to get the
3 | // ping time. The advantage of using this method over the standard ping method is that it permits a more
4 | // event-driven sketch which allows you to appear to do two things at once. An example would be to ping
5 | // an ultrasonic sensor for a possible collision while at the same time navigating. This allows a
6 | // properly developed sketch to multitask. Be aware that because the ping_timer method uses Timer2,
7 | // other features or libraries that also use Timer2 would be effected. For example, the PWM function on
8 | // pins 3 & 11 on Arduino Uno (pins 9 and 11 on Arduino Mega) and the Tone library. Note, only the PWM
9 | // functionality of the pins is lost (as they use Timer2 to do PWM), the pins are still available to use.
10 | // NOTE: For Teensy/Leonardo (ATmega32U4) the library uses Timer4 instead of Timer2.
11 | // ---------------------------------------------------------------------------
12 | #include
13 |
14 | #define TRIGGER_PIN 12 // Arduino pin tied to trigger pin on ping sensor.
15 | #define ECHO_PIN 11 // Arduino pin tied to echo pin on ping sensor.
16 | #define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
17 |
18 | NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
19 |
20 | unsigned int pingSpeed = 50; // How frequently are we going to send out a ping (in milliseconds). 50ms would be 20 times a second.
21 | unsigned long pingTimer; // Holds the next ping time.
22 |
23 | void setup() {
24 | Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
25 | pingTimer = millis(); // Start now.
26 | }
27 |
28 | void loop() {
29 | // Notice how there's no delays in this sketch to allow you to do other processing in-line while doing distance pings.
30 | if (millis() >= pingTimer) { // pingSpeed milliseconds since last ping, do another ping.
31 | pingTimer += pingSpeed; // Set the next ping time.
32 | sonar.ping_timer(echoCheck); // Send out the ping, calls "echoCheck" function every 24uS where you can check the ping status.
33 | }
34 | // Do other stuff here, really. Think of it as multi-tasking.
35 | }
36 |
37 | void echoCheck() { // Timer2 interrupt calls this function every 24uS where you can check the ping status.
38 | // Don't do anything here!
39 | if (sonar.check_timer()) { // This is how you check to see if the ping was received.
40 | // Here's where you can add code.
41 | Serial.print("Ping: ");
42 | Serial.print(sonar.ping_result / US_ROUNDTRIP_CM); // Ping returned, uS result in ping_result, convert to cm with US_ROUNDTRIP_CM.
43 | Serial.println("cm");
44 | }
45 | // Don't do anything here!
46 | }
--------------------------------------------------------------------------------
/libraries/NewPing/examples/NewPingExample/NewPingExample.pde:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------------
2 | // Example NewPing library sketch that does a ping about 20 times per second.
3 | // ---------------------------------------------------------------------------
4 |
5 | #include
6 |
7 | #define TRIGGER_PIN 12 // Arduino pin tied to trigger pin on the ultrasonic sensor.
8 | #define ECHO_PIN 11 // Arduino pin tied to echo pin on the ultrasonic sensor.
9 | #define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
10 |
11 | NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
12 |
13 | void setup() {
14 | Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
15 | }
16 |
17 | void loop() {
18 | delay(50); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
19 | Serial.print("Ping: ");
20 | Serial.print(sonar.ping_cm()); // Send ping, get distance in cm and print result (0 = outside set distance range)
21 | Serial.println("cm");
22 | }
--------------------------------------------------------------------------------
/libraries/NewPing/examples/TimerExample/TimerExample.pde:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------------
2 | // While the NewPing library's primary goal is to interface with ultrasonic sensors, interfacing with
3 | // the Timer2 interrupt was a result of creating an interrupt-based ping method. Since these Timer2
4 | // interrupt methods were built, the library may as well provide the functionality to use these methods
5 | // in your sketches. This shows how simple it is (no ultrasonic sensor required). Keep in mind that
6 | // these methods use Timer2, as does NewPing's ping_timer method for using ultrasonic sensors. You
7 | // can't use ping_timer at the same time you're using timer_ms or timer_us as all use the same timer.
8 | // ---------------------------------------------------------------------------
9 |
10 | #include
11 |
12 | #define LED_PIN 13 // Pin with LED attached.
13 |
14 | void setup() {
15 | pinMode(LED_PIN, OUTPUT);
16 | NewPing::timer_ms(500, toggleLED); // Create a Timer2 interrupt that calls toggleLED in your sketch once every 500 milliseconds.
17 | }
18 |
19 | void loop() {
20 | // Do anything here, the Timer2 interrupt will take care of the flashing LED without your intervention.
21 | }
22 |
23 | void toggleLED() {
24 | digitalWrite(LED_PIN, !digitalRead(LED_PIN)); // Toggle the LED.
25 | }
--------------------------------------------------------------------------------
/libraries/NewPing/keywords.txt:
--------------------------------------------------------------------------------
1 | ###################################
2 | # Syntax Coloring Map For NewPing
3 | ###################################
4 |
5 | ###################################
6 | # Datatypes (KEYWORD1)
7 | ###################################
8 |
9 | NewPing KEYWORD1
10 |
11 | ###################################
12 | # Methods and Functions (KEYWORD2)
13 | ###################################
14 |
15 | ping KEYWORD2
16 | ping_in KEYWORD2
17 | ping_cm KEYWORD2
18 | ping_median KEYWORD2
19 | ping_timer KEYWORD2
20 | check_timer KEYWORD2
21 | timer_us KEYWORD2
22 | timer_ms KEYWORD2
23 | timer_stop KEYWORD2
24 | convert_in KEYWORD2
25 | convert_cm KEYWORD2
26 |
27 | ###################################
28 | # Constants (LITERAL1)
29 | ###################################
30 |
--------------------------------------------------------------------------------
/libraries/Oscillator/Oscillator.cpp:
--------------------------------------------------------------------------------
1 | //--------------------------------------------------------------
2 | //-- Oscillator.pde
3 | //-- Generate sinusoidal oscillations in the servos
4 | //--------------------------------------------------------------
5 | //-- (c) Juan Gonzalez-Gomez (Obijuan), Dec 2011
6 | //-- GPL license
7 | //--------------------------------------------------------------
8 | #if defined(ARDUINO) && ARDUINO >= 100
9 | #include "Arduino.h"
10 | #else
11 | #include "WProgram.h"
12 | #include
13 | #endif
14 | #include "Oscillator.h"
15 | #include
16 |
17 | //-- This function returns true if another sample
18 | //-- should be taken (i.e. the TS time has passed since
19 | //-- the last sample was taken
20 | bool Oscillator::next_sample()
21 | {
22 |
23 | //-- Read current time
24 | _currentMillis = millis();
25 |
26 | //-- Check if the timeout has passed
27 | if(_currentMillis - _previousMillis > _TS) {
28 | _previousMillis = _currentMillis;
29 |
30 | return true;
31 | }
32 |
33 | return false;
34 | }
35 |
36 | //-- Attach an oscillator to a servo
37 | //-- Input: pin is the arduino pin were the servo
38 | //-- is connected
39 | void Oscillator::attach(int pin, bool rev)
40 | {
41 | //-- If the oscillator is detached, attach it.
42 | if(!_servo.attached()){
43 |
44 | //-- Attach the servo and move it to the home position
45 | _servo.attach(pin);
46 | _servo.write(90);
47 |
48 | //-- Initialization of oscilaltor parameters
49 | _TS=30;
50 | _T=2000;
51 | _N = _T/_TS;
52 | _inc = 2*M_PI/_N;
53 |
54 | _previousMillis=0;
55 |
56 | //-- Default parameters
57 | _A=45;
58 | _phase=0;
59 | _phase0=0;
60 | _O=0;
61 | _stop=false;
62 |
63 | //-- Reverse mode
64 | _rev = rev;
65 | }
66 |
67 | }
68 |
69 | //-- Detach an oscillator from his servo
70 | void Oscillator::detach()
71 | {
72 | //-- If the oscillator is attached, detach it.
73 | if(_servo.attached())
74 | _servo.detach();
75 |
76 | }
77 |
78 | /*************************************/
79 | /* Set the oscillator period, in ms */
80 | /*************************************/
81 | void Oscillator::SetT(unsigned int T)
82 | {
83 | //-- Assign the new period
84 | _T=T;
85 |
86 | //-- Recalculate the parameters
87 | _N = _T/_TS;
88 | _inc = 2*M_PI/_N;
89 | };
90 |
91 | /*******************************/
92 | /* Manual set of the position */
93 | /******************************/
94 |
95 | void Oscillator::SetPosition(int position)
96 | {
97 | _servo.write(position+_trim);
98 | };
99 |
100 |
101 | /*******************************************************************/
102 | /* This function should be periodically called */
103 | /* in order to maintain the oscillations. It calculates */
104 | /* if another sample should be taken and position the servo if so */
105 | /*******************************************************************/
106 | void Oscillator::refresh()
107 | {
108 |
109 | //-- Only When TS milliseconds have passed, the new sample is obtained
110 | if (next_sample()) {
111 |
112 | //-- If the oscillator is not stopped, calculate the servo position
113 | if (!_stop) {
114 | //-- Sample the sine function and set the servo pos
115 | _pos = round(_A * sin(_phase + _phase0) + _O);
116 | if (_rev) _pos=-_pos;
117 | _servo.write(_pos+90+_trim);
118 | }
119 |
120 | //-- Increment the phase
121 | //-- It is always increased, even when the oscillator is stop
122 | //-- so that the coordination is always kept
123 | _phase = _phase + _inc;
124 |
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/libraries/Oscillator/Oscillator.h:
--------------------------------------------------------------------------------
1 | //--------------------------------------------------------------
2 | //-- Oscillator.pde
3 | //-- Generate sinusoidal oscillations in the servos
4 | //--------------------------------------------------------------
5 | //-- (c) Juan Gonzalez-Gomez (Obijuan), Dec 2011
6 | //-- GPL license
7 | //--------------------------------------------------------------
8 | #ifndef Oscillator_h
9 | #define Oscillator_h
10 |
11 | #include
12 |
13 | //-- Macro for converting from degrees to radians
14 | #ifndef DEG2RAD
15 | #define DEG2RAD(g) ((g)*M_PI)/180
16 | #endif
17 |
18 | class Oscillator
19 | {
20 | public:
21 | Oscillator(int trim=0) {_trim=trim;};
22 | void attach(int pin, bool rev =false);
23 | void detach();
24 |
25 | void SetA(unsigned int A) {_A=A;};
26 | void SetO(unsigned int O) {_O=O;};
27 | void SetPh(double Ph) {_phase0=Ph;};
28 | void SetT(unsigned int T);
29 | void SetTrim(int trim){_trim=trim;};
30 | int getTrim() {return _trim;};
31 | void SetPosition(int position);
32 | void Stop() {_stop=true;};
33 | void Play() {_stop=false;};
34 | void Reset() {_phase=0;};
35 | void refresh();
36 |
37 | private:
38 | bool next_sample();
39 |
40 | private:
41 | //-- Servo that is attached to the oscillator
42 | Servo _servo;
43 |
44 | //-- Oscillators parameters
45 | unsigned int _A; //-- Amplitude (degrees)
46 | unsigned int _O; //-- Offset (degrees)
47 | unsigned int _T; //-- Period (miliseconds)
48 | double _phase0; //-- Phase (radians)
49 |
50 | //-- Internal variables
51 | int _pos; //-- Current servo pos
52 | int _trim; //-- Calibration offset
53 | double _phase; //-- Current phase
54 | double _inc; //-- Increment of phase
55 | double _N; //-- Number of samples
56 | unsigned int _TS; //-- sampling period (ms)
57 |
58 | long _previousMillis;
59 | long _currentMillis;
60 |
61 | //-- Oscillation mode. If true, the servo is stopped
62 | bool _stop;
63 |
64 | //-- Reverse mode
65 | bool _rev;
66 | };
67 |
68 | #endif
--------------------------------------------------------------------------------
/libraries/Otto/Otto.h:
--------------------------------------------------------------------------------
1 | #ifndef Otto_h
2 | #define Otto_h
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | #include
9 | //#include
10 | #include
11 | #include
12 |
13 | #include "Otto_mouths.h"
14 | #include "Otto_sounds.h"
15 | #include "Otto_gestures.h"
16 |
17 |
18 | //-- Constants
19 | #define FORWARD 1
20 | #define BACKWARD -1
21 | #define LEFT 1
22 | #define RIGHT -1
23 | #define SMALL 5
24 | #define MEDIUM 15
25 | #define BIG 30
26 |
27 | #define PIN_Buzzer 10
28 | #define PIN_Trigger 8
29 | #define PIN_Echo 9
30 | #define PIN_NoiseSensor A6
31 |
32 | /*
33 | DIN - 11, CS- 12, CLK - 13
34 | */
35 | #define PIN_DIN 11
36 | #define PIN_CS 12
37 | #define PIN_CLK 13
38 |
39 |
40 | class Otto
41 | {
42 | public:
43 |
44 | //-- Otto initialization
45 | void init(int YL, int YR, int RL, int RR, bool load_calibration=true, int NoiseSensor=PIN_NoiseSensor, int Buzzer=PIN_Buzzer, int USTrigger=PIN_Trigger, int USEcho=PIN_Echo);
46 |
47 | //-- Attach & detach functions
48 | void attachServos();
49 | void detachServos();
50 |
51 | //-- Oscillator Trims
52 | void setTrims(int YL, int YR, int RL, int RR);
53 | void saveTrimsOnEEPROM();
54 |
55 | //-- Predetermined Motion Functions
56 | void _moveServos(int time, int servo_target[]);
57 | void oscillateServos(int A[4], int O[4], int T, double phase_diff[4], float cycle);
58 |
59 | //-- HOME = Otto at rest position
60 | void home();
61 | bool getRestState();
62 | void setRestState(bool state);
63 |
64 | //-- Predetermined Motion Functions
65 | void jump(float steps=1, int T = 2000);
66 |
67 | void walk(float steps=4, int T=1000, int dir = FORWARD);
68 | void turn(float steps=4, int T=2000, int dir = LEFT);
69 | void bend (int steps=1, int T=1400, int dir=LEFT);
70 | void shakeLeg (int steps=1, int T = 2000, int dir=RIGHT);
71 |
72 | void updown(float steps=1, int T=1000, int h = 20);
73 | void swing(float steps=1, int T=1000, int h=20);
74 | void tiptoeSwing(float steps=1, int T=900, int h=20);
75 | void jitter(float steps=1, int T=500, int h=20);
76 | void ascendingTurn(float steps=1, int T=900, int h=20);
77 |
78 | void moonwalker(float steps=1, int T=900, int h=20, int dir=LEFT);
79 | void crusaito(float steps=1, int T=900, int h=20, int dir=FORWARD);
80 | void flapping(float steps=1, int T=1000, int h=20, int dir=FORWARD);
81 |
82 | //-- Sensors functions
83 | float getDistance(); //US sensor
84 | int getNoise(); //Noise Sensor
85 |
86 | //-- Battery
87 | double getBatteryLevel();
88 | double getBatteryVoltage();
89 |
90 | //-- Mouth & Animations
91 | void putMouth(unsigned long int mouth, bool predefined = true);
92 | void putAnimationMouth(unsigned long int anim, int index);
93 | void clearMouth();
94 |
95 | //-- Sounds
96 | void _tone (float noteFrequency, long noteDuration, int silentDuration);
97 | void bendTones (float initFrequency, float finalFrequency, float prop, long noteDuration, int silentDuration);
98 | void sing(int songName);
99 |
100 | //-- Gestures
101 | void playGesture(int gesture);
102 |
103 |
104 | private:
105 | //LedMatrix ledmatrix;
106 | MaxMatrix ledmatrix=MaxMatrix(PIN_DIN,PIN_CS,PIN_CLK, 1);
107 | BatReader battery;
108 | Oscillator servo[4];
109 | US us;
110 |
111 | int servo_pins[4];
112 | int servo_trim[4];
113 | int servo_position[4];
114 |
115 | int pinBuzzer;
116 | int pinNoiseSensor;
117 |
118 | unsigned long final_time;
119 | unsigned long partial_time;
120 | float increment[4];
121 |
122 | bool isOttoResting;
123 |
124 | unsigned long int getMouthShape(int number);
125 | unsigned long int getAnimShape(int anim, int index);
126 | void _execute(int A[4], int O[4], int T, double phase_diff[4], float steps);
127 |
128 | };
129 |
130 | #endif
131 |
132 |
133 |
--------------------------------------------------------------------------------
/libraries/Otto/Otto_gestures.h:
--------------------------------------------------------------------------------
1 | #ifndef Otto_gestures_h
2 | #define Otto_gestures_h
3 |
4 | //***********************************************************************************
5 | //*********************************GESTURE DEFINES***********************************
6 | //***********************************************************************************
7 |
8 | #define OttoHappy 0
9 | #define OttoSuperHappy 1
10 | #define OttoSad 2
11 | #define OttoSleeping 3
12 | #define OttoFart 4
13 | #define OttoConfused 5
14 | #define OttoLove 6
15 | #define OttoAngry 7
16 | #define OttoFretful 8
17 | #define OttoMagic 9
18 | #define OttoWave 10
19 | #define OttoVictory 11
20 | #define OttoFail 12
21 |
22 | //*** MOUTH ANIMATIONS***
23 | #define littleUuh 0
24 | #define dreamMouth 1
25 | #define adivinawi 2
26 | #define wave 3
27 |
28 |
29 | // unsigned long int littleUuh_code[]={
30 | // 0b00000000000000001100001100000000,
31 | // 0b00000000000000000110000110000000,
32 | // 0b00000000000000000011000011000000,
33 | // 0b00000000000000000110000110000000,
34 | // 0b00000000000000001100001100000000,
35 | // 0b00000000000000011000011000000000,
36 | // 0b00000000000000110000110000000000,
37 | // 0b00000000000000011000011000000000
38 | // };
39 |
40 | // unsigned long int dreamMouth_code[]={
41 | // 0b00000000000000000000110000110000,
42 | // 0b00000000000000010000101000010000,
43 | // 0b00000000011000100100100100011000,
44 | // 0b00000000000000010000101000010000
45 | // };
46 |
47 | // unsigned long int adivinawi_code[]={
48 | // 0b00100001000000000000000000100001,
49 | // 0b00010010100001000000100001010010,
50 | // 0b00001100010010100001010010001100,
51 | // 0b00000000001100010010001100000000,
52 | // 0b00000000000000001100000000000000,
53 | // 0b00000000000000000000000000000000
54 | // };
55 |
56 | // unsigned long int wave_code[]={
57 | // 0b00001100010010100001000000000000,
58 | // 0b00000110001001010000100000000000,
59 | // 0b00000011000100001000010000100000,
60 | // 0b00000001000010000100001000110000,
61 | // 0b00000000000001000010100100011000,
62 | // 0b00000000000000100001010010001100,
63 | // 0b00000000100000010000001001000110,
64 | // 0b00100000010000001000000100000011,
65 | // 0b00110000001000000100000010000001,
66 | // 0b00011000100100000010000001000000
67 | // };
68 |
69 |
70 | #endif
71 |
--------------------------------------------------------------------------------
/libraries/Otto/Otto_mouths.h:
--------------------------------------------------------------------------------
1 | #ifndef Otto_mouths_h
2 | #define Otto_mouths_h
3 |
4 |
5 | //***********************************************************************************
6 | //*********************************MOUTHS DEFINES************************************
7 | //***********************************************************************************
8 |
9 | #define zero_code 0b00001100010010010010010010001100
10 | #define one_code 0b00000100001100000100000100001110
11 | #define two_code 0b00001100010010000100001000011110
12 | #define three_code 0b00001100010010000100010010001100
13 | #define four_code 0b00010010010010011110000010000010
14 | #define five_code 0b00011110010000011100000010011100
15 | #define six_code 0b00000100001000011100010010001100
16 | #define seven_code 0b00011110000010000100001000010000
17 | #define eight_code 0b00001100010010001100010010001100
18 | #define nine_code 0b00001100010010001110000010001110
19 |
20 | #define smile_code 0b00000000100001010010001100000000
21 | #define happyOpen_code 0b00000000111111010010001100000000
22 | #define happyClosed_code 0b00000000111111011110000000000000
23 | #define heart_code 0b00010010101101100001010010001100
24 |
25 | #define bigSurprise_code 0b00001100010010100001010010001100
26 | #define smallSurprise_code 0b00000000000000001100001100000000
27 |
28 | #define tongueOut_code 0b00111111001001001001000110000000
29 | #define vamp1_code 0b00111111101101101101010010000000
30 | #define vamp2_code 0b00111111101101010010000000000000
31 | #define lineMouth_code 0b00000000000000111111000000000000
32 |
33 | #define confused_code 0b00000000001000010101100010000000
34 | #define diagonal_code 0b00100000010000001000000100000010
35 |
36 | #define sad_code 0b00000000001100010010100001000000
37 | #define sadOpen_code 0b00000000001100010010111111000000
38 | #define sadClosed_code 0b00000000001100011110110011000000
39 |
40 | #define okMouth_code 0b00000001000010010100001000000000
41 | #define xMouth_code 0b00100001010010001100010010100001
42 | #define interrogation_code 0b00001100010010000100000100000100
43 |
44 | #define thunder_code 0b00000100001000011100001000010000
45 | #define culito_code 0b00000000100001101101010010000000
46 |
47 | #define angry_code 0b00000000011110100001100001000000
48 |
49 |
50 | //Mouths sorted by numbers, and after, by happy to sad mouths
51 | #define zero 0
52 | #define one 1
53 | #define two 2
54 | #define three 3
55 | #define four 4
56 | #define five 5
57 | #define six 6
58 | #define seven 7
59 | #define eight 8
60 | #define nine 9
61 | #define smile 10
62 | #define happyOpen 11
63 | #define happyClosed 12
64 | #define heart 13
65 | #define bigSurprise 14
66 | #define smallSurprise 15
67 | #define tongueOut 16
68 | #define vamp1 17
69 | #define vamp2 18
70 | #define lineMouth 19
71 | #define confused 20
72 | #define diagonal 21
73 | #define sad 22
74 | #define sadOpen 23
75 | #define sadClosed 24
76 | #define okMouth 25
77 | #define xMouth 26
78 | #define interrogation 27
79 | #define thunder 28
80 | #define culito 29
81 | #define angry 30
82 |
83 |
84 |
85 | #endif
86 |
87 |
88 |
--------------------------------------------------------------------------------
/libraries/Otto/Otto_sounds.h:
--------------------------------------------------------------------------------
1 | #ifndef Otto_sounds_h
2 | #define Otto_sounds_h
3 |
4 | //***********************************************************************************
5 | //*********************************SOUNDS DEFINES************************************
6 | //***********************************************************************************
7 |
8 |
9 | // Reference: This list was adapted from the table located here:
10 | // http://www.phy.mtu.edu/~suits/notefreqs.html
11 | #define note_C0 16.35 //C0
12 | #define note_Db0 17.32 //C#0/Db0
13 | #define note_D0 18.35 //D0
14 | #define note_Eb0 19.45 //D#0/Eb0
15 | #define note_E0 20.6 //E0
16 | #define note_F0 21.83 //F0
17 | #define note_Gb0 23.12 //F#0/Gb0
18 | #define note_G0 24.5 //G0
19 | #define note_Ab0 25.96 //G#0/Ab0
20 | #define note_A0 27.5 //A0
21 | #define note_Bb0 29.14 //A#0/Bb0
22 | #define note_B0 30.87 //B0
23 | #define note_C1 32.7 //C1
24 | #define note_Db1 34.65 //C#1/Db1
25 | #define note_D1 36.71 //D1
26 | #define note_Eb1 38.89 //D#1/Eb1
27 | #define note_E1 41.2 //E1
28 | #define note_F1 43.65 //F1
29 | #define note_Gb1 46.25 //F#1/Gb1
30 | #define note_G1 49 //G1
31 | #define note_Ab1 51.91 //G#1/Ab1
32 | #define note_A1 55 //A1
33 | #define note_Bb1 58.27 //A#1/Bb1
34 | #define note_B1 61.74 //B1
35 | #define note_C2 65.41 //C2 (Middle C)
36 | #define note_Db2 69.3 //C#2/Db2
37 | #define note_D2 73.42 //D2
38 | #define note_Eb2 77.78 //D#2/Eb2
39 | #define note_E2 82.41 //E2
40 | #define note_F2 87.31 //F2
41 | #define note_Gb2 92.5 //F#2/Gb2
42 | #define note_G2 98 //G2
43 | #define note_Ab2 103.83 //G#2/Ab2
44 | #define note_A2 110 //A2
45 | #define note_Bb2 116.54 //A#2/Bb2
46 | #define note_B2 123.47 //B2
47 | #define note_C3 130.81 //C3
48 | #define note_Db3 138.59 //C#3/Db3
49 | #define note_D3 146.83 //D3
50 | #define note_Eb3 155.56 //D#3/Eb3
51 | #define note_E3 164.81 //E3
52 | #define note_F3 174.61 //F3
53 | #define note_Gb3 185 //F#3/Gb3
54 | #define note_G3 196 //G3
55 | #define note_Ab3 207.65 //G#3/Ab3
56 | #define note_A3 220 //A3
57 | #define note_Bb3 233.08 //A#3/Bb3
58 | #define note_B3 246.94 //B3
59 | #define note_C4 261.63 //C4
60 | #define note_Db4 277.18 //C#4/Db4
61 | #define note_D4 293.66 //D4
62 | #define note_Eb4 311.13 //D#4/Eb4
63 | #define note_E4 329.63 //E4
64 | #define note_F4 349.23 //F4
65 | #define note_Gb4 369.99 //F#4/Gb4
66 | #define note_G4 392 //G4
67 | #define note_Ab4 415.3 //G#4/Ab4
68 | #define note_A4 440 //A4
69 | #define note_Bb4 466.16 //A#4/Bb4
70 | #define note_B4 493.88 //B4
71 | #define note_C5 523.25 //C5
72 | #define note_Db5 554.37 //C#5/Db5
73 | #define note_D5 587.33 //D5
74 | #define note_Eb5 622.25 //D#5/Eb5
75 | #define note_E5 659.26 //E5
76 | #define note_F5 698.46 //F5
77 | #define note_Gb5 739.99 //F#5/Gb5
78 | #define note_G5 783.99 //G5
79 | #define note_Ab5 830.61 //G#5/Ab5
80 | #define note_A5 880 //A5
81 | #define note_Bb5 932.33 //A#5/Bb5
82 | #define note_B5 987.77 //B5
83 | #define note_C6 1046.5 //C6
84 | #define note_Db6 1108.73 //C#6/Db6
85 | #define note_D6 1174.66 //D6
86 | #define note_Eb6 1244.51 //D#6/Eb6
87 | #define note_E6 1318.51 //E6
88 | #define note_F6 1396.91 //F6
89 | #define note_Gb6 1479.98 //F#6/Gb6
90 | #define note_G6 1567.98 //G6
91 | #define note_Ab6 1661.22 //G#6/Ab6
92 | #define note_A6 1760 //A6
93 | #define note_Bb6 1864.66 //A#6/Bb6
94 | #define note_B6 1975.53 //B6
95 | #define note_C7 2093 //C7
96 | #define note_Db7 2217.46 //C#7/Db7
97 | #define note_D7 2349.32 //D7
98 | #define note_Eb7 2489.02 //D#7/Eb7
99 | #define note_E7 2637.02 //E7
100 | #define note_F7 2793.83 //F7
101 | #define note_Gb7 2959.96 //F#7/Gb7
102 | #define note_G7 3135.96 //G7
103 | #define note_Ab7 3322.44 //G#7/Ab7
104 | #define note_A7 3520 //A7
105 | #define note_Bb7 3729.31 //A#7/Bb7
106 | #define note_B7 3951.07 //B7
107 | #define note_C8 4186.01 //C8
108 | #define note_Db8 4434.92 //C#8/Db8
109 | #define note_D8 4698.64 //D8
110 | #define note_Eb8 4978.03 //D#8/Eb8
111 |
112 |
113 | #define S_connection 0
114 | #define S_disconnection 1
115 | #define S_buttonPushed 2
116 | #define S_mode1 3
117 | #define S_mode2 4
118 | #define S_mode3 5
119 | #define S_surprise 6
120 | #define S_OhOoh 7
121 | #define S_OhOoh2 8
122 | #define S_cuddly 9
123 | #define S_sleeping 10
124 | #define S_happy 11
125 | #define S_superHappy 12
126 | #define S_happy_short 13
127 | #define S_sad 14
128 | #define S_confused 15
129 | #define S_fart1 16
130 | #define S_fart2 17
131 | #define S_fart3 18
132 |
133 | #endif
134 |
--------------------------------------------------------------------------------
/libraries/OttoSerialCommand/OttoSerialCommand.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Library modified from: "SerialCommand.h" by Steven Cogswell http://awtfy.com
3 | -- Removed portion of the original library to not interfere with interruptions
4 | -- (disable SoftwareSerial support, and thus don't have to use "#include " in the sketches)
5 | */
6 |
7 | #if defined(ARDUINO) && ARDUINO >= 100
8 | #include "Arduino.h"
9 | #else
10 | #include "WProgram.h"
11 | #endif
12 |
13 | #include "OttoSerialCommand.h"
14 |
15 |
16 | #include
17 |
18 |
19 | // Constructor makes sure some things are set.
20 | OttoSerialCommand::OttoSerialCommand()
21 | {
22 | strncpy(delim," ",MAXDELIMETER); // strtok_r needs a null-terminated string
23 | term='\r'; // return character, default terminator for commands
24 | numCommand=0; // Number of callback handlers installed
25 | clearBuffer();
26 | }
27 |
28 |
29 |
30 | //
31 | // Initialize the command buffer being processed to all null characters
32 | //
33 | void OttoSerialCommand::clearBuffer()
34 | {
35 | for (int i=0; i 0)&&(onlyOneCommand==true))
59 | {
60 | int i;
61 | boolean matched;
62 |
63 | inChar=Serial.read(); // Read single available character, there may be more waiting
64 |
65 | if (inChar==term) { // Check for the terminator (default '\r') meaning end of command
66 |
67 | onlyOneCommand=false; //
68 |
69 | bufPos=0; // Reset to start of buffer
70 | token = strtok_r(buffer,delim,&last); // Search for command at start of buffer
71 | if (token == NULL) return;
72 | matched=false;
73 | for (i=0; i SERIALCOMMANDBUFFER-1) bufPos=0; // wrap buffer around if full
97 | }
98 | }
99 | }
100 |
101 | // Adds a "command" and a handler function to the list of available commands.
102 | // This is used for matching a found token in the buffer, and gives the pointer
103 | // to the handler function to deal with it.
104 | void OttoSerialCommand::addCommand(const char *command, void (*function)())
105 | {
106 | if (numCommand < MAXSERIALCOMMANDS) {
107 |
108 | strncpy(CommandList[numCommand].command,command,SERIALCOMMANDBUFFER);
109 | CommandList[numCommand].function = function;
110 | numCommand++;
111 | }
112 | }
113 |
114 | // This sets up a handler to be called in the event that the receveived command string
115 | // isn't in the list of things with handlers.
116 | void OttoSerialCommand::addDefaultHandler(void (*function)())
117 | {
118 | defaultHandler = function;
119 | }
120 |
--------------------------------------------------------------------------------
/libraries/OttoSerialCommand/OttoSerialCommand.h:
--------------------------------------------------------------------------------
1 | /*
2 | Library modified from: "SerialCommand.h" by Steven Cogswell http://awtfy.com
3 | -- Removed portion of the original library to not interfere with interruptions
4 | -- (disable SoftwareSerial support, and thus don't have to use "#include " in the sketches)
5 | */
6 |
7 |
8 |
9 | #ifndef OttoSerialCommand_h
10 | #define OttoSerialCommand_h
11 |
12 | #if defined(ARDUINO) && ARDUINO >= 100
13 | #include "Arduino.h"
14 | #else
15 | #include "WProgram.h"
16 | #endif
17 |
18 |
19 |
20 |
21 | #include
22 |
23 |
24 | #define SERIALCOMMANDBUFFER 35 //16 after changed by me
25 | #define MAXSERIALCOMMANDS 14
26 | #define MAXDELIMETER 2
27 |
28 | class OttoSerialCommand
29 | {
30 | public:
31 | OttoSerialCommand(); // Constructor
32 |
33 | void clearBuffer(); // Sets the command buffer to all '\0' (nulls)
34 | char *next(); // returns pointer to next token found in command buffer (for getting arguments to commands)
35 | void readSerial(); // Main entry point.
36 | void addCommand(const char *, void(*)()); // Add commands to processing dictionary
37 | void addDefaultHandler(void (*function)()); // A handler to call when no valid command received.
38 |
39 | private:
40 | char inChar; // A character read from the serial stream
41 | char buffer[SERIALCOMMANDBUFFER]; // Buffer of stored characters while waiting for terminator character
42 | int bufPos; // Current position in the buffer
43 | char delim[MAXDELIMETER]; // null-terminated list of character to be used as delimeters for tokenizing (default " ")
44 | char term; // Character that signals end of command (default '\r')
45 | char *token; // Returned token from the command buffer as returned by strtok_r
46 | char *last; // State variable used by strtok_r during processing
47 | typedef struct _callback {
48 | char command[SERIALCOMMANDBUFFER];
49 | void (*function)();
50 | } OttoSerialCommandCallback; // Data structure to hold Command/Handler function key-value pairs
51 | int numCommand;
52 | OttoSerialCommandCallback CommandList[MAXSERIALCOMMANDS]; // Actual definition for command/handler array
53 | void (*defaultHandler)(); // Pointer to the default handler function
54 | int usingOttoSoftwareSerial; // Used as boolean to see if we're using OttoSoftwareSerial object or not
55 |
56 | };
57 |
58 | #endif //OttoSerialCommand_h
59 |
--------------------------------------------------------------------------------
/libraries/PS2X_lib/keywords.txt:
--------------------------------------------------------------------------------
1 | #######################################
2 | # Syntax Coloring Map PS2X
3 | #######################################
4 |
5 | #######################################
6 | # Datatypes (KEYWORD1)
7 | #######################################
8 |
9 | PS2X KEYWORD1
10 |
11 | #######################################
12 | # Methods and Functions (KEYWORD2)
13 | #######################################
14 | Button KEYWORD2
15 | ButtonDataByte KEYWORD2
16 | NewButtonState KEYWORD2
17 | ButtonPressed KEYWORD2
18 | ButtonReleased KEYWORD2
19 | read_gamepad KEYWORD2
20 | config_gamepad KEYWORD2
21 | enableRumble KEYWORD2
22 | enablePressures KEYWORD2
23 | Analog KEYWORD2
24 |
25 | #######################################
26 | # Constants (LITERAL1)
27 | #######################################
28 | PSB_SELECT LITERAL1
29 | PSB_L3 LITERAL1
30 | PSB_R3 LITERAL1
31 | PSB_START LITERAL1
32 | PSB_PAD_UP LITERAL1
33 | PSB_PAD_RIGHT LITERAL1
34 | PSB_PAD_DOWN LITERAL1
35 | PSB_PAD_LEFT LITERAL1
36 | PSB_L2 LITERAL1
37 | PSB_R2 LITERAL1
38 | PSB_L1 LITERAL1
39 | PSB_R1 LITERAL1
40 | PSB_GREEN LITERAL1
41 | PSB_RED LITERAL1
42 | PSB_BLUE LITERAL1
43 | PSB_PINK LITERAL1
44 | PSB_TRIANGLE LITERAL1
45 | PSB_CIRCLE LITERAL1
46 | PSB_CROSS LITERAL1
47 | PSB_SQUARE LITERAL1
48 | PSS_RX LITERAL1
49 | PSS_RY LITERAL1
50 | PSS_LX LITERAL1
51 | PSS_LY LITERAL1
52 |
53 | PSAB_PAD_RIGHT LITERAL1
54 | PSAB_PAD_UP LITERAL1
55 | PSAB_PAD_DOWN LITERAL1
56 | PSAB_PAD_LEFT LITERAL1
57 | PSAB_L2 LITERAL1
58 | PSAB_R2 LITERAL1
59 | PSAB_L1 LITERAL1
60 | PSAB_R1 LITERAL1
61 | PSAB_GREEN LITERAL1
62 | PSAB_RED LITERAL1
63 | PSAB_BLUE LITERAL1
64 | PSAB_PINK LITERAL1
65 | PSAB_TRIANGLE LITERAL1
66 | PSAB_CIRCLE LITERAL1
67 | PSAB_CROSS LITERAL1
68 | PSAB_SQUARE LITERAL1
69 |
70 | GREEN_FRET LITERAL1
71 | RED_FRET LITERAL1
72 | YELLOW_FRET LITERAL1
73 | BLUE_FRET LITERAL1
74 | ORANGE_FRET LITERAL1
75 | STAR_POWER LITERAL1
76 | UP_STRUM LITERAL1
77 | DOWN_STRUM LITERAL1
78 | WHAMMY_BAR LITERAL1
79 |
--------------------------------------------------------------------------------
/libraries/US/US.cpp:
--------------------------------------------------------------------------------
1 | #include "US.h"
2 |
3 | //****** US ******//
4 | US::US(){
5 | }
6 |
7 | US::US(int pinTrigger, int pinEcho){
8 | US::init(pinTrigger,pinEcho);
9 | }
10 |
11 | void US::init(int pinTrigger, int pinEcho)
12 | {
13 | _pinTrigger = pinTrigger;
14 | _pinEcho = pinEcho;
15 | pinMode( _pinTrigger , OUTPUT );
16 | pinMode( _pinEcho , INPUT );
17 | }
18 |
19 | long US::TP_init()
20 | {
21 | digitalWrite(_pinTrigger, LOW);
22 | delayMicroseconds(2);
23 | digitalWrite(_pinTrigger, HIGH);
24 | delayMicroseconds(10);
25 | digitalWrite(_pinTrigger, LOW);
26 | long microseconds = pulseIn(_pinEcho,HIGH,40000); //40000
27 | return microseconds;
28 | }
29 |
30 | float US::read(){
31 | long microseconds = US::TP_init();
32 | long distance;
33 | distance = microseconds/29/2;
34 | if (distance == 0){
35 | distance = 999;
36 | }
37 | return distance;
38 | }
--------------------------------------------------------------------------------
/libraries/US/US.h:
--------------------------------------------------------------------------------
1 | #ifndef US_h
2 | #define US_h
3 | #include "Arduino.h"
4 |
5 | class US
6 | {
7 | public:
8 | US();
9 | void init(int pinTrigger, int pinEcho);
10 | US(int pinTrigger, int pinEcho);
11 | float read();
12 |
13 | private:
14 | int _pinTrigger;
15 | int _pinEcho;
16 | long TP_init();
17 |
18 | };
19 |
20 | #endif //US_h
--------------------------------------------------------------------------------
/libraries/readme.txt:
--------------------------------------------------------------------------------
1 | For information on installing libraries, see: http://www.arduino.cc/en/Guide/Libraries
2 |
--------------------------------------------------------------------------------