commit
stringlengths
40
40
old_file
stringlengths
4
264
new_file
stringlengths
4
264
old_contents
stringlengths
0
4.24k
new_contents
stringlengths
1
5.44k
subject
stringlengths
14
778
message
stringlengths
15
9.92k
lang
stringclasses
277 values
license
stringclasses
13 values
repos
stringlengths
5
127k
4de1cab9ec8252991c8ebee9e09f697dd6f28d68
examples/ListDevices/ListDevices.ino
examples/ListDevices/ListDevices.ino
#include <SoftWire.h> #include <AsyncDelay.h> SoftWire sw(SDA, SCL); void setup(void) { Serial.begin(9600); sw.setTimeout_ms(40); sw.begin(); pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); // Set how long we are willing to wait for a device to respond sw.setTimeout_ms(200); const uint8_t firstAddr = 1; const uint8_t lastAddr = 0x7F; Serial.println(); Serial.print("Interrogating all addresses in range 0x"); Serial.print(firstAddr, HEX); Serial.print(" - 0x"); Serial.print(lastAddr, HEX); Serial.println(" (inclusive) ..."); for (uint8_t addr = firstAddr; addr <= lastAddr; addr++) { digitalWrite(LED_BUILTIN, HIGH); delayMicroseconds(10); uint8_t startResult = sw.llStart((addr << 1) + 1); // Signal a read sw.stop(); if (startResult == 0) { Serial.print("\rDevice found at 0x"); Serial.println(addr, HEX); Serial.flush(); } digitalWrite(LED_BUILTIN, LOW); delay(50); } Serial.println("Finished"); } void loop(void) { ; }
Add example to list all addresses where a device is present.
Add example to list all addresses where a device is present.
Arduino
lgpl-2.1
stevemarple/SoftWire
99563bd2559b3a0fd4a4eaea7ae041c5c29c056b
payload/my-payload.ino
payload/my-payload.ino
#include <Wire.h> #include "Adafruit_BMP085.h" /* * BMP180 setup instructions: * ---------------------------------------- * Connect BMP180 V-in to 3.3V (NOT 5.0V) * Connect BMP180 GND to Ground * Connect BMP180 SCL to Analog 5 * Connect BMP180 SDA to Analog 4 * ---------------------------------------- */ Adafruit_BMP085 barometer; void setup() { Serial.begin(9600); // 9600 bits/second if (!barometer.begin()) { Serial.println("No BMP085 sensor found."); while (1) { /* Trap the thread. */ } } } void printBaroData() { // Get temperature. Serial.print("Temperature = "); Serial.print(barometer.readTemperature()); Serial.println(" *C"); // Get pressure at sensor. Serial.print("Pressure = "); Serial.print(barometer.readPressure()); Serial.println(" Pa"); // Calculate pressure at 0 MSL. (0 meters mean sea-level) Serial.print("Calculated pressure at 0 MSL = "); Serial.print(barometer.readSealevelPressure()); Serial.println(" Pa"); // Get pressure altitude: // altitude with (default) altimeter setting at 101325 Pascals == 1013.25 millibars // == 29.92 inches mercury (i.e., std. pressure) Serial.print("Pressure altitude = "); Serial.print(barometer.readAltitude()); Serial.println(" meters"); // TODO: // Density altitude: pressure altitude corrected for nonstandard temperature // High density altitude (High, Hot, and Humid) means decreased performance. // Get indicated altitude: // pressure altitude corrected for non-standard pressure, with altimeter // setting 1015 millibars == 101500 Pascals // For pressure conversions, visit NOAA at: https://www.weather.gov/media/epz/wxcalc/pressureConversion.pdf. Serial.print("Indicated altitude = "); Serial.print(barometer.readAltitude(101500)); Serial.println(" meters"); Serial.println(); } void loop() { printBaroData(); delay(350); }
Add new starting payload program
Add new starting payload program
Arduino
mit
nolanholden/geovis,nolanholden/geovis,nolanholden/payload-level1-rocket,nolanholden/geovis
e68141d20470286c8e56426a8ee51fbb9fb83c16
vor-arduino/YunClient/YunClient.ino
vor-arduino/YunClient/YunClient.ino
/* Yún HTTP Client This example for the Arduino Yún shows how create a basic HTTP client that connects to the internet and downloads content. In this case, you'll connect to the Arduino website and download a version of the logo as ASCII text. created by Tom igoe May 2013 This example code is in the public domain. http://www.arduino.cc/en/Tutorial/HttpClient */ #include <Bridge.h> #include <HttpClient.h> const char* msg = "{\"id\":\"1\",\"type\":\"room\",\"reserved\":false,\"temperature\":10,\"light\":10,\"dioxide\":10,\"noise\":10}"; void setup() { // Bridge takes about two seconds to start up // it can be helpful to use the on-board LED // as an indicator for when it has initialized pinMode(13, OUTPUT); digitalWrite(13, LOW); Bridge.begin(); digitalWrite(13, HIGH); Serial.begin(9600); while (!Serial); // wait for a serial connection } void loop() { // Initialize the client library HttpClient client; client.setHeader("Content-Type: text/plain"); // Make a HTTP request: client.post("rubix.futurice.com/messages", msg); // if there are incoming bytes available // from the server, read them and print them: while (client.available()) { char c = client.read(); Serial.print(c); } Serial.flush(); delay(5000); }
Add HTTP POST for Arduino Yun.
Add HTTP POST for Arduino Yun.
Arduino
mit
futurice/vor,futurice/vor,futurice/vor,futurice/vor,futurice/vor,futurice/vor
b39e3f48018197350d450033d540fad6412c1f52
src/iButton_reader.ino
src/iButton_reader.ino
#include <OneWire.h> #include <EEPROM.h> // This is the pin with the 1-Wire bus on it OneWire ds(PIN_D0); // unique serial number read from the key byte addr[8]; // poll delay (I think 750ms is a magic number for iButton) int del = 1000; // Teensy 2.0 has an LED on port 11 int ledpin = 11; // number of values stored in EEPROM byte n = 0; void setup() { Serial.begin(9600); // wait for serial pinMode(ledpin, OUTPUT); digitalWrite(ledpin, HIGH); while (!Serial.dtr()) {}; digitalWrite(ledpin, LOW); // Dump EEPROM to serial n = EEPROM.read(0); Serial.print(n, DEC); Serial.println(" keys stored:"); int i, j; for(i=0; i<n; i++) { for(j=0; j<8; j++) { Serial.print(EEPROM.read(1 + (8 * i) + j), HEX); Serial.print(" "); } Serial.println(""); } } void loop() { byte result; // search looks through all devices on the bus ds.reset_search(); if(result = !ds.search(addr)) { // Serial.println("Scanning..."); } else if(OneWire::crc8(addr, 7) != addr[7]) { Serial.println("Invalid CRC"); delay(del); return; } else { EEPROM.write(0, n++); Serial.print("Storing key "); Serial.println(n, DEC); for(byte i=0; i<8; i++) { Serial.print(addr[i], HEX); EEPROM.write(1 + (8 * n) + i, addr[i]); Serial.print(" "); } Serial.print("\n"); digitalWrite(ledpin, HIGH); delay(1000); digitalWrite(ledpin, LOW); } delay(del); return; }
Add the Arduino sketch for reading and remembering key numbers. Doesn't build with ino atm.
Add the Arduino sketch for reading and remembering key numbers. Doesn't build with ino atm.
Arduino
mit
katrielalex/iButton_1990a,katrielalex/iButton_1990a
73ab3577a8a90392481a553dad289059bd74bf4a
examples/PIRtest/PIRtest.ino
examples/PIRtest/PIRtest.ino
/**************************************************************************** PIRsensor : test program for PIR sensor module Author: Enrico Formenti Permissions: MIT licence Remarks: - OUT pin is connected to digital pin 2 of Arduino, change this if needed - DELAY times depend on the type of module and/or its configuration. *****************************************************************************/ #include <Serial.h> #include <PIR.h> // OUT pin on PIR sensor connected to digital pin 2 // (any other digital pin will do, just change the value below) #define PIRSensorPin 2 PIR myPIR(PIRSensorPin); void setup() { myPIR.begin(); } void loop() { if(myPIR.getStatus()) { Serial.println("Movement detected"); // do something else at least for the delay between two seccessive // readings delay(myPIR.getDurationDelay()); } else Serial.println("Nothing being detected..."); }
Test program for PIR module
Test program for PIR module
Arduino
bsd-3-clause
maczinga/ASOM,ilFuria/ASOM,ilFuria/ASOM,maczinga/ASOM
4003f73f7f3c7f882d34ed27b24a80c325cfbf25
arduino/serial_server/serial_server.ino
arduino/serial_server/serial_server.ino
/*************************************************** Simple serial server ****************************************************/ //serial String inputString = ""; // a string to hold incoming data boolean stringComplete = false; // whether the string is complete void setup(){ //delay(100); //wait for bus to stabalise // serial Serial.begin(9600); // reserve 200 bytes for the inputString: inputString.reserve(200); } void loop(){ // print the string when a newline arrives: if (stringComplete) { Serial.println(inputString); // clear the string: inputString = ""; stringComplete = false; } } /* SerialEvent occurs whenever a new data comes in the hardware serial RX. This routine is run between each time loop() runs, so using delay inside loop can delay response. Multiple bytes of data may be available. */ void serialEvent() { while (Serial.available()) { // get the new byte: char inChar = (char)Serial.read(); // add it to the inputString: inputString += inChar; // if the incoming character is a newline, set a flag // so the main loop can do something about it: if (inChar == '\n') { stringComplete = true; } } }
Add arduino code to work with the serial_test
Add arduino code to work with the serial_test
Arduino
apache-2.0
Pitchless/arceye,Pitchless/arceye
32877c5c7c19194343cdb955127a29928005ee41
arduino/uno/002_blinky_with_timer1_ovf/002_blinky_with_timer1_ovf.ino
arduino/uno/002_blinky_with_timer1_ovf/002_blinky_with_timer1_ovf.ino
/** * Copyright (c) 2019, Łukasz Marcin Podkalicki <lpodkalicki@gmail.com> * ArduinoUno/001 * Blinky with timer1 OVF. */ #define LED_PIN (13) #define TIMER_TCNT (57723) // 65536 - 16MHz/1024/2 void setup() { pinMode(LED_PIN, OUTPUT); // set LED pin as output TCCR1A = 0; TCCR1B = _BV(CS12)|_BV(CS10); // set Timer1 prescaler to 1024 TIMSK1 |= _BV(TOIE1); // enable Timer1 overflow interrupt TCNT1 = TIMER_TCNT; // reload timer counter } void loop() { // do nothing } ISR(TIMER1_OVF_vect) { TCNT1 = TIMER_TCNT; // reload timer counter digitalWrite(LED_PIN, !digitalRead(LED_PIN)); // Toggle LED pin }
Add next Arduino example - blinky with Timer1 OVF.
Add next Arduino example - blinky with Timer1 OVF.
Arduino
bsd-3-clause
lpodkalicki/blog,lpodkalicki/blog,lpodkalicki/blog,lpodkalicki/blog,lpodkalicki/blog,lpodkalicki/blog
cfdb1ea52de1889cd6aeb4a10498e46c7a16ddc6
night_sensor/night_feature_arduino_testbed.ino
night_sensor/night_feature_arduino_testbed.ino
""" @author: Sze 'Ron' Chau @source: https://github.com/wodiesan/senior_design_spring @Desc: Adafruit Analog Light Sensor, modified by Ron Chau. 1. Connect sensor output to Analog Pin 0 2. Connect 5v to VCC and GND to GND 3. Connect 3.3v to the AREF pin """ int led1 = 2; // LED connected to digital pin 2 int led2 = 3; // LED connected to digital pin 3 int led3 = 4; // LED connected to digital pin 4 int sensorPin = A0; // select the input pin for the potentiometer float rawRange = 1024; // 3.3v float logRange = 5.0; // 3.3v = 10^5 lux // Random value chosen to test light sensing feature. float lightLimit = 600; void setup() { analogReference(EXTERNAL); // Serial.begin(9600); Serial.println("Adafruit Analog Light Sensor Test"); //LEF pins pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); } void loop() { // read the raw value from the sensor: int rawValue = analogRead(sensorPin); Serial.print("Raw = "); Serial.print(rawValue); Serial.print(" - Lux = "); Serial.println(RawToLux(rawValue)); // LEDS on if rawValue greater or equal. if(rawValue <= 400){ digitalWrite(led1, HIGH); // LED on digitalWrite(led2, HIGH); digitalWrite(led3, HIGH); } else{ digitalWrite(led1, LOW); // LEDs off digitalWrite(led2, LOW); digitalWrite(led3, LOW); } delay(1000); } float RawToLux(int raw) { float logLux = raw * logRange / rawRange; return pow(10, logLux); }
Add basic GA1A12S202 light sensor Arduino testbed.
Add basic GA1A12S202 light sensor Arduino testbed.
Arduino
mit
wodiesan/senior_design_spring
264556b335e9df7a367a57be814a649b3362c744
examples/More/PrintAllVirtual/PrintAllVirtual.ino
examples/More/PrintAllVirtual/PrintAllVirtual.ino
/************************************************************** * Blynk is a platform with iOS and Android apps to control * Arduino, Raspberry Pi and the likes over the Internet. * You can easily build graphic interfaces for all your * projects by simply dragging and dropping widgets. * * Downloads, docs, tutorials: http://www.blynk.cc * Blynk community: http://community.blynk.cc * Social networks: http://www.fb.com/blynkapp * http://twitter.com/blynk_app * * Blynk library is licensed under MIT license * This example code is in public domain. * ************************************************************** * This sketch prints all virtual pin operations! * **************************************************************/ #define BLYNK_PRINT Serial #include <SPI.h> #include <Ethernet.h> #include <BlynkSimpleEthernet.h> // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "YourAuthToken"; void setup() { Serial.begin(9600); // See the connection status in Serial Monitor Blynk.begin(auth); } // This is called for all virtual pins, that don't have BLYNK_WRITE handler BLYNK_WRITE_DEFAULT() { BLYNK_LOG("V%d input: ", request.pin); // Print all parameter values for (auto i = param.begin(); i < param.end(); ++i) { BLYNK_LOG("* %s", i.asString()); } } // This is called for all virtual pins, that don't have BLYNK_READ handler BLYNK_READ_DEFAULT() { // Generate random response int val = random(0, 100); BLYNK_LOG("V%d output: %d", request.pin, val); Blynk.virtualWrite(request.pin, val); } void loop() { Blynk.run(); }
Print all virtual data example
Print all virtual data example
Arduino
mit
ivankravets/blynk-library,blynkkk/blynk-library,ivankravets/blynk-library,ivankravets/blynk-library,blynkkk/blynk-library,blynkkk/blynk-library,ivankravets/blynk-library,blynkkk/blynk-library,ivankravets/blynk-library,blynkkk/blynk-library
bb640b987aa5898e00f16f5c86752ee70a1f8c83
Tests/webClient/webClient.ino
Tests/webClient/webClient.ino
// Demo using DHCP and DNS to perform a web client request. // 2011-06-08 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php #include <EtherCard.h> // ethernet interface mac address, must be unique on the LAN static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; byte Ethernet::buffer[600]; static uint32_t timer; const char website[] PROGMEM = "www.sweeparis.com"; // called when the client request is complete static void my_callback (byte status, word off, word len) { Serial.println(">>>"); Serial.print(off);Serial.print("/");Serial.print(len);Serial.print(">>>"); Ethernet::buffer[min(699, off + len)] = 0; Serial.print((const char*) Ethernet::buffer + off); Serial.println("..."); } void setup () { Serial.begin(57600); Serial.println(F("\n[webClient]")); if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) Serial.println(F("Failed to access Ethernet controller")); if (!ether.dhcpSetup()) Serial.println(F("DHCP failed")); ether.printIp("IP: ", ether.myip); ether.printIp("GW: ", ether.gwip); ether.printIp("DNS: ", ether.dnsip); if (!ether.dnsLookup(website)) Serial.println("DNS failed"); ether.printIp("SRV: ", ether.hisip); } void loop () { ether.packetLoop(ether.packetReceive()); delay(100); if (millis() > timer) { timer = millis() + 10000; Serial.println(); Serial.print("<<< REQ "); ether.browseUrl(PSTR("/riot-server/"), "", website, my_callback); } }
Add tests for web client
Add tests for web client
Arduino
mit
totothekiller/weather-station,totothekiller/weather-station
10407c036751bad172a50bc5df6a2ea9945b73c9
Examples/findBaudTest/findBaudTest.ino
Examples/findBaudTest/findBaudTest.ino
/* * findBaudTest - Test all supported baud settings * * The progress and results are printed to Serial, so open the 'Serial * Montitor'. * * The progress and results will be easier to read if you disable the * debugging (comment out or delete the "#define DEBUG_HC05" line in * HC05.h. */ #include <Arduino.h> #include "HC05.h" #ifdef HC05_SOFTWARE_SERIAL #include <SoftwareSerial.h> HC05 btSerial = HC05(A2, A5, A3, A4); // cmd, state, rx, tx #else HC05 btSerial = HC05(3, 2); // cmd, state #endif void setup() { DEBUG_BEGIN(57600); Serial.begin(57600); btSerial.findBaud(); btSerial.setBaud(4800); Serial.println("---------- Starting test ----------"); } void loop() { int numTests = 0; int failed = 0; unsigned long rate = 0; unsigned long rates[] = {4800,9600,19200,38400,57600,115200}; for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { numTests++; Serial.print(rates[i]); btSerial.setBaud(rates[i]); rate = btSerial.findBaud(); if (rate != rates[i]) { Serial.print(" FAILED: found rate "); Serial.println(rate); failed++; } else { Serial.print("->"); Serial.print(rates[j]); btSerial.setBaud(rates[j]); rate = btSerial.findBaud(); if (rate != rates[j]) { Serial.print("FAILED: found rate "); Serial.println(rate); failed++; } else { Serial.println(" PASSED"); } } } } Serial.println("--------- Tests Complete ----------"); Serial.print("Results: "); Serial.print(failed); Serial.print(" of "); Serial.print(numTests); Serial.println(" tests failed."); while (true) { ; } }
Add example of setbaud and findbaud
Add example of setbaud and findbaud On branch parityAndStopBits new file: Examples/findBaudTest/findBaudTest.ino
Arduino
mit
jdunmire/HC05
d40ecb0c0de30b1b7b5160ca8d0d7dd3aec5ed65
arduino/BLEDigitalPot/BLEDigitalPot.ino
arduino/BLEDigitalPot/BLEDigitalPot.ino
/* Digital Potentiometer control over BLE MCP4110 digital Pots SPI interface */ // inslude the SPI library: #include <SPI.h> #include <SoftwareSerial.h> SoftwareSerial bleSerial(2, 3); // RX, TX // set pot select pin const int potSS = 10; //const int potWriteCmd = B00100011; const int potWriteCmd = B00010011; void setup() { // set output pins: pinMode(potSS, OUTPUT); // initialize SPI: SPI.begin(); //initialize serial port for logs Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } bleSerial.begin(9600); // digitalPotWrite(0); } void loop() { // //test // digitalPotWrite(pot1SS,36); // delay(100); // Wire.readByte(); if (bleSerial.available()) { int val = bleSerial.read(); Serial.write("value = "); Serial.print(val,DEC); digitalPotWrite(val); } if (Serial.available()) { bleSerial.write(Serial.read()); } } void digitalPotWrite(int value) { // put the SS pin to low in order to select the chip: digitalWrite(potSS, LOW); SPI.transfer(potWriteCmd); SPI.transfer(value); // put the SS pin to high for transfering the data digitalWrite(potSS, HIGH); }
Add simple program that sets the first recived byte by BLE and write in the pot
Add simple program that sets the first recived byte by BLE and write in the pot
Arduino
apache-2.0
kikermo/PotsOverBLE
8895e7344467860c17b634cbe62e71cec4dae6b2
examples/GSM-Serial/GSM-Serial.ino
examples/GSM-Serial/GSM-Serial.ino
#include <SoftwareSerial.h> SoftwareSerial SSerial(10, 11); void setup(void) { Serial.begin(9600); SSerial.begin(9600); } void loop(void) { if (Serial.available() > 0) { SSerial.write(Serial.read()); } if (SSerial.available() > 0) { Serial.write(SSerial.read()); } }
Add GSM Serial for testing AT Command
Add GSM Serial for testing AT Command
Arduino
mit
Atnic/GSM-library
b67382758740b149603d25df774c1699e8859ebb
examples/Time/CosaSince/CosaSince.ino
examples/Time/CosaSince/CosaSince.ino
/** * @file CosaSince.ino * @version 1.0 * * @section License * Copyright (C) 2015, Mikael Patel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * @section Description * Verify Watchdog::since() and RTC::since() wrap-around behavior. * * This file is part of the Arduino Che Cosa project. */ #include "Cosa/RTC.hh" #include "Cosa/Trace.hh" #include "Cosa/Watchdog.hh" #include "Cosa/OutputPin.hh" #include "Cosa/IOStream/Driver/UART.hh" OutputPin led(Board::LED); // Start time in milli-seconds const uint32_t START = 0xfffff000UL; void setup() { uart.begin(9600); trace.begin(&uart, PSTR("CosaSince: started")); trace.flush(); // Start timers. Use RTC::delay() Watchdog::begin(); RTC::begin(); // Set timers to the start time Watchdog::millis(START); RTC::millis(START); } void loop() { led.on(); uint32_t rms = RTC::millis(); uint32_t wms = Watchdog::millis(); uint32_t wsd = Watchdog::since(START); uint32_t rsd = RTC::since(START); int32_t diff = wsd - rsd; trace << RTC::seconds() << ':' << rms << ':' << wms << ':' << rsd << ':' << wsd << ':' << diff << ':' << diff / Watchdog::ms_per_tick() << endl; delay(1000 - RTC::since(rms)); led.off(); delay(1000); }
Add sketch to verify Watchdog/RTC::since() behavior.
Add sketch to verify Watchdog/RTC::since() behavior.
Arduino
lgpl-2.1
dansut/Cosa,jeditekunum/Cosa,mikaelpatel/Cosa,jeditekunum/Cosa,dansut/Cosa,jeditekunum/Cosa,mikaelpatel/Cosa,jeditekunum/Cosa,mikaelpatel/Cosa,dansut/Cosa,mikaelpatel/Cosa,dansut/Cosa
5bf376b143af61a9ada7fa510535659383ecbcb7
posttodatasparkfun/posttodatasparkfun.ino
posttodatasparkfun/posttodatasparkfun.ino
#include "DHT.h" #define DHTPIN 2 // what pin we're connected to // Uncomment whatever type you're using! #define DHTTYPE DHT11 // DHT 11 //#define DHTTYPE DHT22 // DHT 22 (AM2302) //#define DHTTYPE DHT21 // DHT 21 (AM2301) // Connect pin 1 (on the left) of the sensor to +5V // NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1 // to 3.3V instead of 5V! // Connect pin 2 of the sensor to whatever your DHTPIN is // Connect pin 4 (on the right) of the sensor to GROUND // Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor // Initialize DHT sensor for normal 16mhz Arduino DHT dht(DHTPIN, DHTTYPE); // Phant arduino lib // git clone https://github.com/sparkfun/phant-arduino ~/sketchbook/libraries/Phant #include <Phant.h> // Arduino example stream // http://data.sparkfun.com/streams/VGb2Y1jD4VIxjX3x196z // hostname, public key, private key Phant phant("data.sparkfun.com", "VGb2Y1jD4VIxjX3x196z", "9YBaDk6yeMtNErDNq4YM"); #include <EtherCard.h> byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; byte Ethernet::buffer[700]; Stash stash; const char website[] PROGMEM = "google.com"; void setup() { Serial.begin(9600); dht.begin(); if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) Serial.println(F("Failed to access Ethernet controller")); if (!ether.dhcpSetup()) Serial.println(F("DHCP failed")); ether.printIp("IP: ", ether.myip); ether.printIp("GW: ", ether.gwip); ether.printIp("DNS: ", ether.dnsip); if (!ether.dnsLookup(website)) Serial.println(F("DNS failed")); Serial.println("Setup completed"); } void loop() { // Reading temperature or humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) float h = dht.readHumidity(); // Read temperature as Celsius float t = dht.readTemperature(); phant.add("humidity", h); phant.add("temperature", t); Serial.println("Sending data..."); byte sd = stash.create(); stash.println(phant.post()); stash.save(); ether.tcpSend(); // Wait a few seconds between measurements. delay(10000); }
Add example of Iot device that posts to data.sparkfun.com
Add example of Iot device that posts to data.sparkfun.com
Arduino
mit
JanKlopper/IoTv1
0de90038405c886e3bb49b9b223c3067e346cf23
Functionality/SetupTemplate/SetupTemplate/SetupTemplate.ino
Functionality/SetupTemplate/SetupTemplate/SetupTemplate.ino
//Skript for testing the input-values of the arduino by displaying values in the serial monitor int delayTime = 4000; int buttonState = 0; int piezo = A0; int photo = A1; int poti = A2; int switchBtn = 11; int buttonBtn = 12; int extFlash = 8; int camTrigger = 9; int camFocus = 10; int piezoValue = 0; int photoValue = 0; int potiValue = 0; int btnState = 0; int switchState = 0; void setup() { Serial.begin(9600); pinMode(piezo, INPUT); pinMode(photo, INPUT); pinMode(poti, INPUT); pinMode(switchBtn, INPUT); pinMode(buttonBtn, INPUT); pinMode(extFlash, OUTPUT); pinMode(camTrigger, OUTPUT); pinMode(camFocus, OUTPUT); } void loop() { if(readSensors() == true) { takePicture(); } delay(delayTime); } int readSensors() { piezoValue = analogRead(piezo); photoValue = analogRead(photo); potiValue = analogRead(poti); btnState = digitalRead(buttonBtn); switchState = digitalRead(switchBtn); Serial.print("Piezo-Wert : ");Serial.println(piezoValue); Serial.print("Photo-Resistor : ");Serial.println(photoValue); Serial.print("Potentiometer : ");Serial.println(potiValue); Serial.print("Taster : ");Serial.println(btnState); Serial.print("Schalter : ");Serial.println(switchState); Serial.println(" "); return(true); } void takePicture() { // do stuff here }
Test input values by displaying in the serial monitor
Test input values by displaying in the serial monitor
Arduino
mit
jeroendoggen/Arduino-Interactive
458548a18a6793397dbe44e714908987e7c12890
examples/TeensyDMXSend/TeensyDMXSend.ino
examples/TeensyDMXSend/TeensyDMXSend.ino
#include <TeensyDmx.h> #define DMX_REDE 2 byte DMXVal[] = {50}; // This isn't required for DMX sending, but the code currently requires it. struct RDMINIT rdmData { "TeensyDMX v0.1", "Teensyduino", 1, // Device ID "DMX Node", 1, // The DMX footprint 0, // The DMX startAddress - only used for RDM 0, // Additional commands length for RDM 0 // Definition of additional commands }; TeensyDmx Dmx(Serial1, &rdmData, DMX_REDE); void setup() { Dmx.setMode(TeensyDmx::DMX_OUT); } void loop() { Dmx.setChannels(0,DMXVal,1); Dmx.loop(); }
Add a DMX send example
Add a DMX send example
Arduino
mit
chrisstaite/TeensyDmx,chrisstaite/TeensyDmx,chrisstaite/TeensyDmx
c020d269faca9397c96a60c15ff555f8675e17bf
arduino/interrupt_test/interrupt_test.ino
arduino/interrupt_test/interrupt_test.ino
/****************************************************************************************************************************\ * * Arduino interrupt tests, as simple and understandable as possible. * © Aapo Rista 2017, MIT license * Tested with Wemos ESP8266 D1 Mini PRO * https://www.wemos.cc/product/d1-mini-pro.html * \*************************************************************************************************************************/ // const byte interruptPin = 2; // D4 on Wemos ESP8266 const byte interruptPin = D4; // If the board is correctly set in Arduino IDE, you can use D1, D2 etc. directly volatile byte interruptCounter = 0; int numberOfInterrupts = 0; int state = 0; void setup() { Serial.begin(115200); Serial.println(); Serial.println("Start"); // pinMode(interruptPin, INPUT_PULLUP); // Only one interrupt type can be attached to a GPIO pin at a time // attachInterrupt(digitalPinToInterrupt(interruptPin), handleInterrupt, FALLING); // attachInterrupt(digitalPinToInterrupt(interruptPin), handleInterrupt, RISING); attachInterrupt(digitalPinToInterrupt(interruptPin), handleInterrupt, CHANGE); } void handleInterrupt() { interruptCounter++; state = digitalRead(interruptPin); } void loop() { if(interruptCounter>0){ interruptCounter--; numberOfInterrupts++; Serial.print("Interrupt "); if (state == 1) { Serial.print(" RISING"); } else { Serial.print("FALLING"); } Serial.print(" at "); Serial.print(millis()); Serial.print(" ms uptime. Total: "); Serial.println(numberOfInterrupts); } }
Add simple interrupt test script
Add simple interrupt test script
Arduino
mit
aapris/CernWall,aapris/CernWall
ec9a34623ee52a752b5cd67c2c83af1aaaf44960
AL_ILI9341/examples/DrawTextWithScale/DrawTextWithScale.ino
AL_ILI9341/examples/DrawTextWithScale/DrawTextWithScale.ino
#include "AL_ILI9341.h" #include "AL_Font.h" // Wiring #define TFT_PORT PORTF #define TFT_PIN PINF #define TFT_DDR DDRF #define TFT_RST A12 #define TFT_CS A11 #define TFT_RS A10 #define TFT_WR A9 #define TFT_RD A8 AL_ILI9341 tft( &TFT_PORT, &TFT_PIN, &TFT_DDR, TFT_RST, TFT_CS, TFT_RS, TFT_WR, TFT_RD); AL_RgbColor backColor{255, 255, 255}; AL_RgbColor text1Color{255, 0, 0}; AL_RgbColor text2Color{0, 255, 0}; AL_RgbColor text3Color{0, 0, 255}; AL_RgbColor text4Color{0, 255, 255}; AL_RgbColor text5Color{255, 255, 0}; void setup() { tft.setup(); tft.setOrientation(AL_SO_LANDSCAPE2); tft.fillRect(0, 0, tft.getWidth(), tft.getHeight(), backColor); tft.drawText(10, 10, text1Color, backColor, 1, "hello"); tft.drawText(10, 26, text2Color, backColor, 2, "hello"); tft.drawText(10, 58, text3Color, backColor, 3, "hello"); tft.drawText(10, 106, text4Color, backColor, 4, "hello"); tft.drawText(10, 170, text5Color, backColor, 5, "hello"); } void loop() { }
Add draw text with scale example.
Add draw text with scale example.
Arduino
mit
anders-liu/arduino-libs,anders-liu/arduino-libs
51e3e5cfd4065f8b6e64c072124e4aa4156d7e5c
experiments/NewPing4Sensors/NewPing4Sensors.ino
experiments/NewPing4Sensors/NewPing4Sensors.ino
#include <NewPing.h> #define SONAR_NUM 4 // Number or sensors. #define MAX_DISTANCE 200 // Maximum distance (in cm) to ping. #define PING_INTERVAL 33 // Milliseconds between sensor pings (29ms is about the min to avoid cross-sensor echo). unsigned long pingTimer[SONAR_NUM]; // Holds the times when the next ping should happen for each sensor. unsigned int cm[SONAR_NUM]; // Where the ping distances are stored. uint8_t currentSensor = 0; // Keeps track of which sensor is active. NewPing sonar[SONAR_NUM] = { // Sensor object array. NewPing(11, 12, MAX_DISTANCE), // Each sensor's trigger pin, echo pin, and max distance to ping. NewPing(9, 10, MAX_DISTANCE), NewPing(2, 3, MAX_DISTANCE), NewPing(5, 6, MAX_DISTANCE) }; void setup() { Serial.begin(115200); pingTimer[0] = millis() + 75; // First ping starts at 75ms, gives time for the Arduino to chill before starting. for (uint8_t i = 1; i < SONAR_NUM; i++) // Set the starting time for each sensor. pingTimer[i] = pingTimer[i - 1] + PING_INTERVAL; } void loop() { for (uint8_t i = 0; i < SONAR_NUM; i++) { // Loop through all the sensors. if (millis() >= pingTimer[i]) { // Is it this sensor's time to ping? pingTimer[i] += PING_INTERVAL * SONAR_NUM; // Set next time this sensor will be pinged. if (i == 0 && currentSensor == SONAR_NUM - 1) oneSensorCycle(); // Sensor ping cycle complete, do something with the results. sonar[currentSensor].timer_stop(); // Make sure previous timer is canceled before starting a new ping (insurance). currentSensor = i; // Sensor being accessed. cm[currentSensor] = 0; // Make distance zero in case there's no ping echo for this sensor. sonar[currentSensor].ping_timer(echoCheck); // Do the ping (processing continues, interrupt will call echoCheck to look for echo). } } // The rest of your code would go here. } void echoCheck() { // If ping received, set the sensor distance to array. if (sonar[currentSensor].check_timer()) cm[currentSensor] = sonar[currentSensor].ping_result / US_ROUNDTRIP_CM; } void oneSensorCycle() { // Sensor ping cycle complete, do something with the results. for (uint8_t i = 0; i < SONAR_NUM; i++) { Serial.print(i); Serial.print("="); Serial.print(cm[i]); Serial.print("cm "); } Serial.println(); }
Add test sketch for SR-04 ultasound sensors
Add test sketch for SR-04 ultasound sensors
Arduino
mit
jonnor/synchrony
dcee5d7193185b37a38b9ae981f744a3034f8171
Arduino/LightTestPattern/LightTestPattern.ino
Arduino/LightTestPattern/LightTestPattern.ino
// Program for testing a single strip of lights. // Cycles through each possible combination of pure colors: // #000000 #FF0000 #00FF00 #FFFF00 #0000FF #FF00FF #00FFFF #FFFFFF // For each color, lights up lights one at a time with a slight delay between // individual lights, then leaves the whole strip lit up for 2 seconds. #include <FAB_LED.h> const uint8_t numPixels = 20; apa106<D, 6> LEDstrip; rgb pixels[numPixels] = {}; void setup() { } void loop() { static int color; for (int i = 0; i < numPixels; ++i) { pixels[i].r = !!(color & 1) * 255; pixels[i].g = !!(color & 2) * 255; pixels[i].b = !!(color & 4) * 255; delay(100); LEDstrip.sendPixels(numPixels, pixels); } color = (color + 1) % 8; // Display the pixels on the LED strip. LEDstrip.sendPixels(numPixels, pixels); delay(2000); }
Add Arduino sketch for testing individual strips
Add Arduino sketch for testing individual strips This program cycles through all patterns of fully lit R, G, and B lights in a known pattern at a known rate, so we can test each strip as it is made.
Arduino
mit
godlygeek/LightRender,MaddAddaM/LightRender
b9e83b8733d2058a911d076ba7a98d9e4882c9eb
arduino/VoteVisualizer.ino
arduino/VoteVisualizer.ino
// VoteVisualization // // Author: sven.mentl@gmail.com // Released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library #include <Adafruit_NeoPixel.h> #include <avr/power.h> // Digital I/O Pin connected to Data In of the NeoPixel Ring #define PIN 13 // Number of NeoPixels #define NUMPIXELS 24 // Configuration of NeoPixels Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); // Constants const uint32_t RED = pixels.Color(255, 0, 0); const uint32_t GREEN = pixels.Color(0, 255, 0); const uint32_t BLUE = pixels.Color(0, 0, 255); const uint32_t OFF = pixels.Color(0, 0, 0); const int START_SEQUENCE_BLINK_DELAY = 200; void setup() { // Setup the serial connection Serial.begin(9600); // Initialize the NeoPixel library pixels.begin(); // Display the start sequence to show that the right code is loaded and that the arduino is ready to be used startSequence(); } void loop() { // Blocking call if (Serial.available() > 0) { // A value between 0 and 1 is expected on the serial line. // The value expresses the ratio of positive votes in relation to all votes. float ratio = Serial.parseFloat(); if(ratio < 0 || ratio > 1) return; int numberOfGreens = (ratio * 24)+0.5; lightFirstXInGreenRestInRed(numberOfGreens); } } void lightFirstXInGreenRestInRed(int numberOfGreens){ for(int i=0; i<numberOfGreens; i++){ pixels.setPixelColor(i, GREEN); } for(int i=0+numberOfGreens; i<NUMPIXELS; i++){ pixels.setPixelColor(i, RED); } pixels.show(); } void startSequence(){ for(int j=0; j<10; j++){ lightAllLeds(BLUE); delay(START_SEQUENCE_BLINK_DELAY); lightAllLeds(OFF); delay(START_SEQUENCE_BLINK_DELAY); } } void lightAllLeds(uint32_t color) { for(int i=0; i<NUMPIXELS; i++){ pixels.setPixelColor(i, color); } pixels.show(); }
Add working code for the arduino uno
Add working code for the arduino uno
Arduino
mit
mentlsve/ta-conf-codejam,mentlsve/ta-conf-codejam
d47561e524cfc3f454e99fc1294e6a609cdd5660
arduino/rover-movement/rover-movement.ino
arduino/rover-movement/rover-movement.ino
/* * Author: Manuel Parra Z. * Date: 14/11/2015 * License: MIT License * Materials: * - Arduino Uno R3 * - DFRobot DF-MD V1.3 * - DFRobot Pirate 4WD * Description: * This sketch will use as a movement test, first the rover will go foward * on the track, then it will go reverse, then will turn to left and finally * will turn to right. This sketch will show you the if you connected the * engines and batteries properly. Don't forget to review the fritzing * electronic diagram in the document section of the project */ int M1 = 4; int E1 = 5; int E2 = 6; int M2 = 7; void setup() { Serial.begin(9600); pinMode(M1, OUTPUT); pinMode(E1, OUTPUT); pinMode(M2, OUTPUT); pinMode(E2, OUTPUT); Serial.println("Setup finished."); } void loop() { Serial.println("Foward for 3 seconds."); digitalWrite(M1, HIGH); digitalWrite(M2, HIGH); analogWrite(E1, 200); analogWrite(E2, 200); delay(3000); Serial.println("Reverse for 3 seconds."); digitalWrite(M1, LOW); digitalWrite(M2, LOW); analogWrite(E1, 200); analogWrite(E2, 200); delay(3000); Serial.println("Left for 3 seconds."); digitalWrite(M1, LOW); digitalWrite(M2, HIGH); analogWrite(E1, 200); analogWrite(E2, 200); delay(3000); Serial.println("Right for 3 seconds."); digitalWrite(M1, HIGH); digitalWrite(M2, LOW); analogWrite(E1, 200); analogWrite(E2, 200); delay(3000); }
Add the arduino sketch to test the rover movement.
Add the arduino sketch to test the rover movement.
Arduino
mit
mparra-mpz/Pathfinder,mparra-mpz/Pathfinder
6808c111ef9cbb2f86cbbac42905935670b8240f
examples/TMC2130_AccelStepper/TMC2130_AccelStepper.ino
examples/TMC2130_AccelStepper/TMC2130_AccelStepper.ino
/** * Author Teemu Mäntykallio * Initializes the library and turns the motor in alternating directions. */ #define EN_PIN 38 // Nano v3: 16 Mega: 38 //enable (CFG6) #define DIR_PIN 55 // 19 55 //direction #define STEP_PIN 54 // 18 54 //step #define CS_PIN 40 // 17 40 //chip select constexpr uint32_t steps_per_mm = 80; #include <TMC2130Stepper.h> TMC2130Stepper driver = TMC2130Stepper(EN_PIN, DIR_PIN, STEP_PIN, CS_PIN); #include <AccelStepper.h> AccelStepper stepper = AccelStepper(stepper.DRIVER, STEP_PIN, DIR_PIN); void setup() { Serial.begin(9600); while(!Serial); Serial.println("Start..."); pinMode(CS_PIN, OUTPUT); digitalWrite(CS_PIN, HIGH); driver.begin(); // Initiate pins and registeries driver.rms_current(600); // Set stepper current to 600mA. The command is the same as command TMC2130.setCurrent(600, 0.11, 0.5); driver.stealthChop(1); // Enable extremely quiet stepping driver.stealth_autoscale(1); driver.microsteps(16); stepper.setMaxSpeed(50*steps_per_mm); // 100mm/s @ 80 steps/mm stepper.setAcceleration(1000*steps_per_mm); // 2000mm/s^2 stepper.setEnablePin(EN_PIN); stepper.setPinsInverted(false, false, true); stepper.enableOutputs(); } void loop() { if (stepper.distanceToGo() == 0) { stepper.disableOutputs(); delay(100); stepper.move(100*steps_per_mm); // Move 100mm stepper.enableOutputs(); } stepper.run(); }
Add example for pairing with AccelStepper library
Add example for pairing with AccelStepper library
Arduino
agpl-3.0
teemuatlut/TMC2130Stepper
2da8253e2ffe1448183e1e01bd3d9aa3c6db7b74
examples/Boards_BLE/RedBearLab_BLE_Mini/RedBearLab_BLE_Mini.ino
examples/Boards_BLE/RedBearLab_BLE_Mini/RedBearLab_BLE_Mini.ino
/************************************************************** * Blynk is a platform with iOS and Android apps to control * Arduino, Raspberry Pi and the likes over the Internet. * You can easily build graphic interfaces for all your * projects by simply dragging and dropping widgets. * * Downloads, docs, tutorials: http://www.blynk.cc * Blynk community: http://community.blynk.cc * Social networks: http://www.fb.com/blynkapp * http://twitter.com/blynk_app * * Blynk library is licensed under MIT license * This example code is in public domain. * ************************************************************** * * This example shows how to use Arduino + RedBearLab BLE Mini * to connect your project to Blynk. * * NOTE: BLE support is in beta! * **************************************************************/ //#define BLYNK_DEBUG #define BLYNK_PRINT Serial #define BLYNK_USE_DIRECT_CONNECT #include <BlynkSimpleSerialBLE.h> // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "YourAuthToken"; #define SerialBLE Serial1 // Set Serial object void setup() { // This is for debug prints Serial.begin(9600); SerialBLE.begin(57600); // BLE Mini uses baud 57600 Blynk.begin(auth, SerialBLE); } void loop() { Blynk.run(); }
Add RedBearLab BLE Mini module
Add RedBearLab BLE Mini module
Arduino
mit
ivankravets/blynk-library,blynkkk/blynk-library,ivankravets/blynk-library,ivankravets/blynk-library,blynkkk/blynk-library,blynkkk/blynk-library,blynkkk/blynk-library,ivankravets/blynk-library,ivankravets/blynk-library,blynkkk/blynk-library
2655521317c622bb7f429ffefbf60e254d69faff
examples/Boards_WiFi/Arduino_MKR1010/Arduino_MKR1010.ino
examples/Boards_WiFi/Arduino_MKR1010/Arduino_MKR1010.ino
/************************************************************* Download latest Blynk library here: https://github.com/blynkkk/blynk-library/releases/latest Blynk is a platform with iOS and Android apps to control Arduino, Raspberry Pi and the likes over the Internet. You can easily build graphic interfaces for all your projects by simply dragging and dropping widgets. Downloads, docs, tutorials: http://www.blynk.cc Sketch generator: http://examples.blynk.cc Blynk community: http://community.blynk.cc Follow us: http://www.fb.com/blynkapp http://twitter.com/blynk_app Blynk library is licensed under MIT license This example code is in public domain. ************************************************************* This example shows how to use Arduino MKR 1010 to connect your project to Blynk. Note: This requires WiFiNINA library from http://librarymanager/all#WiFiNINA Feel free to apply it to any other example. It's simple! *************************************************************/ /* Comment this out to disable prints and save space */ #define BLYNK_PRINT Serial #define BLYNK_DEBUG #include <SPI.h> #include <WiFiNINA.h> #include <BlynkSimpleWiFiNINA.h> // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "YourAuthToken"; // Your WiFi credentials. // Set password to "" for open networks. char ssid[] = "YourNetworkName"; char pass[] = "YourPassword"; void setup() { // Debug console Serial.begin(9600); while (!Serial) {} Blynk.begin(auth, ssid, pass); // You can also specify server: //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80); //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080); } void loop() { Blynk.run(); }
Add WiFiNINA, Arduino MKR WiFi 1010 support
Add WiFiNINA, Arduino MKR WiFi 1010 support
Arduino
mit
blynkkk/blynk-library,blynkkk/blynk-library,blynkkk/blynk-library,blynkkk/blynk-library,blynkkk/blynk-library
84736d29ca795c611fac40a1f4a03bc330debca0
examples/mqtt_qos/mqtt_qos.ino
examples/mqtt_qos/mqtt_qos.ino
/* MQTT with QoS example - connects to an MQTT server - publishes "hello world" to the topic "outTopic" with a variety of QoS values */ #include <ESP8266WiFi.h> #include <PubSubClient.h> const char *ssid = "xxxxxxxx"; // cannot be longer than 32 characters! const char *pass = "yyyyyyyy"; // // Update these with values suitable for your network. IPAddress server(172, 16, 0, 2); void callback(String topic, byte* payload, unsigned int length) { // handle message arrived } PubSubClient client(server); void setup() { // Setup console Serial.begin(115200); delay(10); Serial.println(); Serial.println(); client.set_callback(callback); WiFi.begin(ssid, pass); int retries = 0; while ((WiFi.status() != WL_CONNECTED) && (retries < 10)) { retries++; delay(500); Serial.print("."); } if (WiFi.status() == WL_CONNECTED) { Serial.println(""); Serial.println("WiFi connected"); } if (client.connect("arduinoClient")) { client.publish("outTopic", "hello world qos=0"); // Simple publish with qos=0 client.publish(MQTT::Publish("outTopic", "hello world qos=1") .set_qos(1, client.next_packet_id())); client.publish(MQTT::Publish("outTopic", "hello world qos=2") .set_qos(2, client.next_packet_id())); } } void loop() { client.loop(); }
Add an example showing how to set the QoS value of a message to publish
Add an example showing how to set the QoS value of a message to publish
Arduino
mit
hemantsangwan/Arduino-PubSubClient,liquiddandruff/pubsubclient,doebi/pubsubclient,liquiddandruff/pubsubclient,hemantsangwan/Arduino-PubSubClient,Imroy/pubsubclient,vshymanskyy/pubsubclient,liquiddandruff/pubsubclient,Protoneer/pubsubclient,koltegirish/pubsubclient,Imroy/pubsubclient,koltegirish/pubsubclient,vshymanskyy/pubsubclient,vshymanskyy/pubsubclient,Protoneer/pubsubclient,Imroy/pubsubclient,doebi/pubsubclient,koltegirish/pubsubclient,doebi/pubsubclient,hemantsangwan/Arduino-PubSubClient,Protoneer/pubsubclient
5da3776db3aabdfa6a88247e99633040ac111fee
Arduino/ADXL335_LEDs/ADXL335_LEDs.ino
Arduino/ADXL335_LEDs/ADXL335_LEDs.ino
// Arduino example that streams accelerometer data from an ADXL335 // (or other three-axis analog accelerometer) to the ESP system and // lights different LEDs depending on the predictions made by the // ESP system. Use with the user_accelerometer_gestures.cpp ESP example. // the accelerometer pins int zpin = A3; int ypin = A4; int xpin = A5; // the LED pins int redpin = 9; int greenpin = 10; int bluepin = 11; // These are only used if you're plugging the ADXL335 (on the // Adafruit breakout board) directly into the analog input pins // of your Arduino. See comment below. int vinpin = A0; int voutpin = A1; int gndpin = A2; void setup() { Serial.begin(115200); // Lower the serial timeout (from its default value of 1000 ms) // so that the call to Serial.parseInt() below doesn't pause for // too long and disrupt the sending of accelerometer data. Serial.setTimeout(2); // Uncomment the following lines if you're using an ADXL335 on an // Adafruit breakout board (https://www.adafruit.com/products/163) // and want to plug it directly into (and power it from) the analog // input pins of your Arduino board. // pinMode(vinpin, OUTPUT); digitalWrite(vinpin, HIGH); // pinMode(gndpin, OUTPUT); digitalWrite(gndpin, LOW); // pinMode(voutpin, INPUT); pinMode(xpin, INPUT); pinMode(ypin, INPUT); pinMode(zpin, INPUT); } void loop() { Serial.print(analogRead(xpin)); Serial.print("\t"); Serial.print(analogRead(ypin)); Serial.print("\t"); Serial.print(analogRead(zpin)); Serial.println(); delay(10); // Check for a valid prediction. int val = Serial.parseInt(); if (val != 0) { // Turn off all the LEDs. analogWrite(redpin, 0); analogWrite(greenpin, 0); analogWrite(bluepin, 0); // Turn on the LED corresponding to the prediction. if (val == 1) analogWrite(redpin, 255); if (val == 2) analogWrite(greenpin, 255); if (val == 3) analogWrite(bluepin, 255); } }
Add Arduino example that receives ESP predictions over serial.
Add Arduino example that receives ESP predictions over serial. Fixes #192.
Arduino
bsd-3-clause
damellis/ESP,damellis/ESP
043882b7ca18a7b87e45782433563eda7e00bf8a
examples/IRInvertModulate/IRInvertModulate.ino
examples/IRInvertModulate/IRInvertModulate.ino
/* * IRremote: IRInvertModulate - demonstrates the ability enable/disable * IR signal modulation and inversion. * An IR LED must be connected to Arduino PWM pin 3. * To view the results, attach an Oscilloscope or Signal Analyser across the * legs of the IR LED. * Version 0.1 November, 2013 * Copyright 2013 Aaron Snoswell * http://elucidatedbinary.com */ #include <IRremote.h> IRsend irsend; void setup() { Serial.begin(9600); Serial.println("Welcome, visitor"); Serial.println("Press 'm' to toggle IR modulation"); Serial.println("Press 'i' to toggle IR inversion"); } bool modulate = true; bool invert = false; void loop() { if (!Serial.available()) { // Send some random data irsend.sendNEC(0xa90, 12); } else { char c; do { c = Serial.read(); } while(Serial.available()); if(c == 'm') { modulate = !modulate; if(modulate) Serial.println("Enabling Modulation"); else Serial.println("Disabling Modulation"); irsend.enableIRModulation(modulate); } else if(c == 'i') { invert = !invert; if(invert) Serial.println("Enabling Invert"); else Serial.println("Disabling Invert"); irsend.enableIRInvert(invert); } else { Serial.println("Unknown Command"); } } delay(300); }
Add demo on new functionality
Add demo on new functionality This demo shows how the new functionality added here can be used - it allows the user to interactively toggle IR signal modulation and inversion using the serial connection.
Arduino
lgpl-2.1
aaronsnoswell/Arduino-IRremote,aaronsnoswell/Arduino-IRremote
a97cdb9d689761247baa374e80544e6171b6cca6
Device_LinkItOne/Example/Sensor-GroveMoisture/Sensor-GroveMoisture.ino
Device_LinkItOne/Example/Sensor-GroveMoisture/Sensor-GroveMoisture.ino
int sensorPin = A1; // select the input pin for the potentiometer float sensorValue[0]; float get_sensor_data_moisture(){ // read the value from the sensor: return analogRead(sensorPin); } void setup() { // declare the ledPin as an OUTPUT: Serial.begin(115200); } void loop() { sensorValue[0]=get_sensor_data_moisture(); Serial.print("sensor = " ); Serial.println(sensorValue[0]); delay(1000); }
Bring up verification of GroveMoisture
Bring up verification of GroveMoisture
Arduino
mit
LinkItONEDevGroup/LASS,LinkItONEDevGroup/LASS,LinkItONEDevGroup/LASS,LinkItONEDevGroup/LASS,LinkItONEDevGroup/LASS,LinkItONEDevGroup/LASS,LinkItONEDevGroup/LASS,LinkItONEDevGroup/LASS,LinkItONEDevGroup/LASS,LinkItONEDevGroup/LASS
b14ac4752490cfa84faf269c26b576ae57956be4
examples/mqtt_will/mqtt_will.ino
examples/mqtt_will/mqtt_will.ino
/* MQTT "will" message example - connects to an MQTT server with a will message - publishes a message - waits a little bit - disconnects the socket *without* sending a disconnect packet You should see the will message published when we disconnect */ #include <ESP8266WiFi.h> #include <PubSubClient.h> const char *ssid = "xxxxxxxx"; // cannot be longer than 32 characters! const char *pass = "yyyyyyyy"; // // Update these with values suitable for your network. IPAddress server(172, 16, 0, 2); WiFiClient wclient; PubSubClient client(wclient, server); void setup() { // Setup console Serial.begin(115200); delay(10); Serial.println(); Serial.println(); } void loop() { delay(1000); if (WiFi.status() != WL_CONNECTED) { Serial.print("Connecting to "); Serial.print(ssid); Serial.println("..."); WiFi.begin(ssid, pass); if (WiFi.waitForConnectResult() != WL_CONNECTED) return; Serial.println("WiFi connected"); } if (WiFi.status() == WL_CONNECTED) { MQTT::Connect con("arduinoClient"); con.set_will("test", "I am down."); // Or to set a binary message: // char msg[4] = { 0xde, 0xad, 0xbe, 0xef }; // con.set_will("test", msg, 4); if (client.connect(con)) { client.publish("test", "I am up!"); delay(1000); wclient.stop(); } else Serial.println("MQTT connection failed."); delay(10000); } }
Add example sketch for testing out "will" messages
Add example sketch for testing out "will" messages
Arduino
mit
Imroy/pubsubclient,Imroy/pubsubclient,Imroy/pubsubclient
df8aa21c55f8872fc7697db822c34f46c24e2e14
DOCS/line_follow_head_test/line_follow_head_test.ino
DOCS/line_follow_head_test/line_follow_head_test.ino
#define FAR_LEFT A0 #define LEFT A1 #define CENTER_LEFT A2 #define CENTER_RIGHT A3 #define RIGHT A4 #define FAR_RIGHT A5 #define WB_THRESHOLD 400 #define IR_DELAY 140 void setup() { Serial.begin(9600); pinMode(FAR_LEFT, INPUT); pinMode(LEFT, INPUT); pinMode(CENTER_LEFT, INPUT); pinMode(CENTER_RIGHT, INPUT); pinMode(RIGHT, INPUT); pinMode(FAR_RIGHT, INPUT); pinMode(LED_BUILTIN, OUTPUT); } boolean toDigital(uint8_t pin){ int reading = analogRead(pin); delayMicroseconds(IR_DELAY); // Serial.println(reading); return reading > WB_THRESHOLD; } void print_digital_readings(){ boolean far_left = toDigital(FAR_LEFT); boolean left = toDigital(LEFT); boolean center_left = toDigital(CENTER_LEFT); boolean center_right = toDigital(CENTER_RIGHT); boolean right = toDigital(RIGHT); boolean far_right = toDigital(FAR_RIGHT); Serial.print(far_left); Serial.print("\t"); Serial.print(left); Serial.print("\t"); Serial.print(center_left); Serial.print("\t"); Serial.print(center_right); Serial.print("\t"); Serial.print(right); Serial.print("\t"); Serial.println(far_right); } void print_analog_readings(){ int far_left = analogRead(FAR_LEFT); int left = analogRead(LEFT); int center_left = analogRead(CENTER_LEFT); int center_right = analogRead(CENTER_RIGHT); int right = analogRead(RIGHT); int far_right = analogRead(FAR_RIGHT); Serial.print(far_left); Serial.print("\t"); Serial.print(left); Serial.print("\t"); Serial.print(center_left); Serial.print("\t"); Serial.print(center_right); Serial.print("\t"); Serial.print(right); Serial.print("\t"); Serial.println(far_right); } void loop(){ print_analog_readings(); //print_digital_readings(); delay(20); }
Test code for the line follow
Test code for the line follow
Arduino
mit
Vido/sumobot,Vido/sumobot
b4e7ee95e42252ffa95ae64f98409df26fc67f4e
software/main/Blink.ino
software/main/Blink.ino
/* Blink Turns on an LED on for one second, then off for one second, repeatedly. Most Arduinos have an on-board LED you can control. On the Uno and Leonardo, it is attached to digital pin 13. If you're unsure what pin the on-board LED is connected to on your Arduino model, check the documentation at http://arduino.cc This example code is in the public domain. modified 8 May 2014 by Scott Fitzgerald */ // the setup function runs once when you press reset or power the board void setup() { // initialize digital pin 13 as an output. pinMode(13, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(13, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }
Add blink file too for ease of access
Add blink file too for ease of access
Arduino
mit
ieee-uiuc/arduino-workshop,ieee-uiuc/arduino-workshop
8db0a34be842d063a0a774d0b83018d7a21e041f
arduino_stepper/arduino_stepper.ino
arduino_stepper/arduino_stepper.ino
/* Stepper Motor Control */ #include <Stepper.h> const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution // for your motor // initialize the stepper library on pins 8 through 11: Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11); int stepCount = 0; // number of steps the motor has taken int stepValue = 0; // current step number the motor is on void setup() { // initialize the serial port: Serial.begin(9600); myStepper.setSpeed(200); } void loop() { // step one step: myStepper.step(1); //Serial.print("steps:"); Serial.println(stepValue); //Serial.print("degrees: "); //Serial.println(stepCount*1.8); stepCount++; stepValue = stepCount + 1; if (stepValue > 200) { stepValue = stepValue - 200; } delay(100); }
Add arduino stepper motor control
Add arduino stepper motor control
Arduino
mit
the-raspberry-pi-guy/lidar
e84a408adc56e2155082e16ade32020551c281ea
gliderCutdown/gliderCutdown.ino
gliderCutdown/gliderCutdown.ino
#include <Servo.h> Servo myservo; int pos = 0; void setup() { myservo.attach(9); myservo.write(45); // Start out in a good position delay(5000); // Wait as long as you like. (milliseconds) } void loop() { myservo.write(130) // End in a release position while(true); // Do nothing, forever. }
Add super simple arduino servo-based cutdown program.
Add super simple arduino servo-based cutdown program.
Arduino
mit
LBCC-SpaceClub/HAB2017,LBCC-SpaceClub/HAB2017,LBCC-SpaceClub/HAB2017
f2b3c325d2161e6b5f60fca44e675b05a445caa5
SimpleTest/SimpleTest.ino
SimpleTest/SimpleTest.ino
void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); Keyboard.begin(); //setup buttons pinMode(2, INPUT_PULLUP); //Button 1 pinMode(3, INPUT_PULLUP); //Button 2 pinMode(4, INPUT_PULLUP); //Button 3 pinMode(5, INPUT_PULLUP); //Button 4 //setup mainboard connection pinMode(6, OUTPUT); //Reset pin digitalWrite(6, LOW); //active high pulse pinMode(7, OUTPUT); //Power on pin digitalWrite(7, LOW); //active high pulse //setup coin detector pinMode(8, INPUT_PULLUP); //Coin 1 pinMode(9, INPUT_PULLUP); //Coin 2 pinMode(10, INPUT_PULLUP); //Coin 3 pinMode(11, INPUT_PULLUP); //Reject button pinMode(12, OUTPUT); //Accept all coins digitalWrite(12, LOW); } void loop() { // read the input pin: int buttonState2 = digitalRead(2); int buttonState3 = digitalRead(3); int buttonState4 = digitalRead(4); int buttonState5 = digitalRead(5); int buttonState8 = digitalRead(8); int buttonState9 = digitalRead(9); int buttonState10 = digitalRead(10); int buttonState11 = digitalRead(11); // print out the state of the buttons: Serial.print(buttonState2); Serial.print(buttonState3); Serial.print(buttonState4); Serial.print(buttonState5); Serial.print(buttonState8); Serial.print(buttonState9); Serial.print(buttonState10); Serial.print(buttonState11); Serial.print('\n'); delay(25); // delay in between reads for stability if(buttonState2 == LOW) { Keyboard.write('A'); digitalWrite(6, HIGH); //push reset } else { digitalWrite(6, LOW); } if(buttonState3 == LOW) { Keyboard.write('B'); digitalWrite(7, HIGH); //push power } else { digitalWrite(7, LOW); } if(buttonState4 == LOW) { Keyboard.write('C'); } if(buttonState5 == LOW) { Keyboard.write('D'); } if(buttonState8 == LOW) { Keyboard.write('1'); } if(buttonState9 == LOW) { Keyboard.write('2'); } if(buttonState10 == LOW) { Keyboard.write('3'); } }
Add simple Arduino test program
Add simple Arduino test program
Arduino
bsd-2-clause
HorstBaerbel/MAMEduino,HorstBaerbel/MAMEduino,HorstBaerbel/MAMEduino
cb9c287214a56a46afc161faec49b90a1c1bff30
examples/Tools/CosaAutoCalibration/CosaAutoCalibration.ino
examples/Tools/CosaAutoCalibration/CosaAutoCalibration.ino
/** * @file CosaAutoCalibration.ino * @version 1.0 * * @section License * Copyright (C) 2015, Mikael Patel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * @section Description * Calibrate Watchdog clock with RTC clock as reference. Automatically * adjust Watchdog clock to RTC clock tick. * * This file is part of the Arduino Che Cosa project. */ #include "Cosa/RTC.hh" #include "Cosa/Watchdog.hh" #include "Cosa/Trace.hh" #include "Cosa/IOStream/Driver/UART.hh" RTC::Clock clock; Watchdog::Clock bark; void setup() { // Start trace output stream on the serial port uart.begin(57600); trace.begin(&uart, PSTR("CosaAutoCalibration: started")); // Start the watchdog and internal real-time clock Watchdog::begin(); RTC::begin(); // Synchronized clocks uint32_t now = clock.await(); delay(500); bark.time(now + 1); } void loop() { static int32_t cycle = 1; // Wait for clock update uint32_t now = clock.await(); // Calculate error and possible adjustment int32_t diff = bark.time() - now; int32_t err = (1000 * diff) / cycle; if (err != 0) { bark.adjust(err / 2); trace << endl << PSTR("calibration=") << bark.calibration() << endl; cycle = 1; clock.time(0); now = clock.await(); delay(500); bark.time(now + 1); } else { trace << '.'; cycle += 1; } }
Add a tool for auto calibration of watchdog based clock.
Add a tool for auto calibration of watchdog based clock.
Arduino
lgpl-2.1
jeditekunum/Cosa,jeditekunum/Cosa,mikaelpatel/Cosa,jeditekunum/Cosa,dansut/Cosa,mikaelpatel/Cosa,mikaelpatel/Cosa,dansut/Cosa,mikaelpatel/Cosa,jeditekunum/Cosa,dansut/Cosa,dansut/Cosa
acb0f06ce9e4bc95b05e68726a70de5eca4043df
Kirbi/testing/lidar_serial/lidar_serial.ino
Kirbi/testing/lidar_serial/lidar_serial.ino
// set this to the hardware serial port you wish to use #define HWSERIAL Serial1 byte byteArray [9]; // Byte0 Byte 1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7 Byte8 // 0x89 0x89 Dist_L Dist_H Strength_L Strength_H Temp_L Temp_H Checksum // byte2 is distance, overflows into byte3 byte configOutput [5] = {0x5A, 0x05, 0x07, 0x01, 0x11}; // write this array to HWSERIAL to enable output byte configUART [5] = {0x5A, 0x05, 0x0A, 0x00, 0x11}; // write this array to HWSERIAL to set sensor to UART mode // more config commands on datasheet https://acroname.com/sites/default/files/assets/sj-gu-tfmini_plus-01-a04-datasheet_en.pdf void setup() { Serial.begin(115200); HWSERIAL.begin(115200);// default baud rate HWSERIAL.write(configUART, 5); // set sensor to UART mode HWSERIAL.write(configOutput, 5); // enable output } void loop() { if (HWSERIAL.available() > 0) { HWSERIAL.readBytes(byteArray, 9); // write output of read to an array of length 9 for (int i =0;i<9;i++){ Serial.println(byteArray[i]); } } }
Add TFmini plus (lidar) test code
Add TFmini plus (lidar) test code
Arduino
mit
simplyellow/auto-sumo
225563b994ed25df458cd817349bd2d1aa4f50ec
tinkering/motor/button_op_enable/button_op_enable.ino
tinkering/motor/button_op_enable/button_op_enable.ino
#include <Stepper.h> #define P1 P4_5 #define P2 P1_1 const int stepsPerRevolution = 200; Stepper myStepper(stepsPerRevolution, 12,13,5,9); short forward; short backward; void setup() { // set the speed at 60 rpm: myStepper.setSpeed(60); // initialize the serial port: Serial.begin(9600); // Enable pin pull-up for the buttons pinMode(P4_5, INPUT_PULLUP); pinMode(P1_1, INPUT_PULLUP); // Set modes for enable pins pinMode(18, OUTPUT); pinMode(19, OUTPUT); } void loop() { // Read button pins forward = digitalRead(P1); backward = digitalRead(P2); Serial.print(forward); // Enable or disable motor if (forward == 0 || backward == 0) { digitalWrite(18, HIGH); digitalWrite(19, HIGH); } else { digitalWrite(18, LOW); digitalWrite(19, LOW); } // Turn motor if a button is pressed if (forward == 0) { myStepper.step(1); } if (backward == 0) { myStepper.step(-1); } // Delay before next loop. Determines how fast the motor turns delay(4); }
Test for motor using enable pins and buttons operation.
Test for motor using enable pins and buttons operation.
Arduino
mit
fkmclane/derailleurs,fkmclane/derailleurs,fkmclane/derailleurs
a827db4891ed8d89920e9474a2c33b4cfd3d8666
examples/sendFD/sendFD.ino
examples/sendFD/sendFD.ino
// demo: CAN-BUS Shield, send data // loovee@seeed.cc #include <SPI.h> #include "mcp2518fd_can.h" /*SAMD core*/ #ifdef ARDUINO_SAMD_VARIANT_COMPLIANCE #define SERIAL SerialUSB #else #define SERIAL Serial #endif #define CAN_2518FD // the cs pin of the version after v1.1 is default to D9 // v0.9b and v1.0 is default D10 const int SPI_CS_PIN = BCM8; #ifdef CAN_2518FD mcp2518fd CAN(SPI_CS_PIN); // Set CS pin #endif void setup() { SERIAL.begin(115200); while(!Serial){}; CAN.setMode(0); while (0 != CAN.begin((byte)CAN_500K_1M)) { // init can bus : baudrate = 500k SERIAL.println("CAN BUS Shield init fail"); SERIAL.println(" Init CAN BUS Shield again"); delay(100); } byte mode = CAN.getMode(); SERIAL.printf("CAN BUS get mode = %d\n\r",mode); SERIAL.println("CAN BUS Shield init ok!"); } unsigned char stmp[64] = {0}; void loop() { // send data: id = 0x00, standrad frame, data len = 8, stmp: data buf stmp[63] = stmp[63] + 1; if (stmp[63] == 100) { stmp[63] = 0; stmp[63] = stmp[63] + 1; if (stmp[6] == 100) { stmp[6] = 0; stmp[5] = stmp[6] + 1; } } CAN.sendMsgBuf(0x00, 0, 15, stmp); delay(100); // send data per 100ms SERIAL.println("CAN BUS sendMsgBuf ok!"); } // END FILE
Add canbus FD send example
Add canbus FD send example
Arduino
mit
Seeed-Studio/CAN_BUS_Shield,Seeed-Studio/CAN_BUS_Shield
1e85aea9084d828bf5524e146a938e0d052ae126
test/ecdsa_test/ecdsa_test.ino
test/ecdsa_test/ecdsa_test.ino
#include <uECC.h> #include <j0g.h> #include <js0n.h> #include <lwm.h> #include <bitlash.h> #include <GS.h> #include <SPI.h> #include <Wire.h> #include <Scout.h> #include <Shell.h> #include <uECC.h> extern "C" { static int RNG(uint8_t *p_dest, unsigned p_size) { while(p_size) { long v = random(); unsigned l_amount = min(p_size, sizeof(long)); memcpy(p_dest, &v, l_amount); p_size -= l_amount; p_dest += l_amount; } return 1; } void px(uint8_t *v, uint8_t num) { uint8_t i; for(i=0; i<num; ++i) { Serial.print(v[i]); Serial.print(" "); } Serial.println(); } } void setup() { Scout.setup(); uint8_t l_private[uECC_BYTES]; uint8_t l_public[uECC_BYTES * 2]; uint8_t l_hash[uECC_BYTES]; uint8_t l_sig[uECC_BYTES*2]; Serial.print("Testing ECDSA\n"); uECC_set_rng(&RNG); for(;;) { unsigned long a = millis(); if(!uECC_make_key(l_public, l_private)) { Serial.println("uECC_make_key() failed"); continue; } unsigned long b = millis(); Serial.print("Made key 1 in "); Serial.println(b-a); memcpy(l_hash, l_public, uECC_BYTES); a = millis(); if(!uECC_sign(l_private, l_hash, l_sig)) { Serial.println("uECC_sign() failed\n"); continue; } b = millis(); Serial.print("ECDSA sign in "); Serial.println(b-a); a = millis(); if(!uECC_verify(l_public, l_hash, l_sig)) { Serial.println("uECC_verify() failed\n"); continue; } b = millis(); Serial.print("ECDSA verify in "); Serial.println(b-a); } } void loop() { // put your main code here, to run repeatedly: }
Add ECDSA test for Arduino
Add ECDSA test for Arduino
Arduino
bsd-2-clause
cgommel/micro-ecc,phoenix-frozen/micro-ecc,adfernandes/micro-ecc,cgommel/micro-ecc,adfernandes/micro-ecc,cgommel/micro-ecc,kmackay/micro-ecc,carlescufi/micro-ecc,periloso/micro-ecc,kmackay/micro-ecc,adfernandes/micro-ecc,concise/micro-ecc,kmackay/micro-ecc,phoenix-frozen/micro-ecc,concise/micro-ecc,carlescufi/micro-ecc,adfernandes/micro-ecc,periloso/micro-ecc,carlescufi/micro-ecc,kmackay/micro-ecc,periloso/micro-ecc
d7f55225e87aabd3ce9018b1f82cd2ad58a96f42
4/readbutton.ino
4/readbutton.ino
int BUTTON_PIN = 2; void setup() { pinMode(BUTTON_PIN, INPUT); Serial.begin(9600); } void loop() { //Serial.println("Hello computer!"); //Serial.print("This line will mash together with the next."); int buttonPressed = digitalRead(BUTTON_PIN); if(buttonPressed == 1) { Serial.println("I pressed the button, and the button is:"); Serial.println(buttonPressed); } }
Add sketch for reading button press
Add sketch for reading button press
Arduino
bsd-2-clause
peplin/electronics-and-programming-class
2b4d414b24f4321ff3cf27542c38b42afe7be2c9
libraries/LCD/CosaLCDverify/CosaLCDverify.ino
libraries/LCD/CosaLCDverify/CosaLCDverify.ino
/** * @file CosaLCDverify.ino * @version 1.0 * * @section License * Copyright (C) 2015, Mikael Patel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * @section Description * Verify build of all implementations of LCD and adapters. * * This file is part of the Arduino Che Cosa project. */ #include <HD44780.h> #include <PCF8574.h> #include <MJKDZ_LCD_Module.h> #include <GY_IICLCD.h> #include <DFRobot_IIC_LCD_Module.h> #include <SainSmart_LCD2004.h> #include <MCP23008.h> #include <Adafruit_I2C_LCD_Backpack.h> #include <ERM1602_5.h> #include <Canvas.h> #include <PCD8544.h> #include <ST7565.h> #include <VLCD.h>
Add sketch that includes all LCD interface implementations and adapters.
Add sketch that includes all LCD interface implementations and adapters.
Arduino
lgpl-2.1
jeditekunum/Cosa,jeditekunum/Cosa,dansut/Cosa,dansut/Cosa,jeditekunum/Cosa,mikaelpatel/Cosa,mikaelpatel/Cosa,mikaelpatel/Cosa,jeditekunum/Cosa,dansut/Cosa,mikaelpatel/Cosa,dansut/Cosa
ccdf20ed7ac901142983cd004e82e5a8f4821d6a
examples/evothings.bluetooth_discovery/firmware/Token_fw_BEANHW.ino
examples/evothings.bluetooth_discovery/firmware/Token_fw_BEANHW.ino
// Token's firmware working copy // Code based on RFDUINO hardware, uses C char arrays #include <ArduinoJson.h> //Test JSON strings char OFF[]= "{\"device\":\"LED\",\"event\":\"off\"}"; char GREEN[] = "{\"device\":\"LED\",\"event\":\"on\",\"color\":\"green\"}"; char RED[] = "{\"device\":\"LED\",\"event\":\"on\",\"color\":\"red\"}"; char BLUE[] = "{\"device\":\"LED\",\"event\":\"on\",\"color\":\"blue\"}"; char WHITE[] = "{\"device\":\"LED\",\"event\":\"on\",\"color\":\"white\"}"; void setup() { //Serial.begin(9600); //Streams debug messagges over the serial port DEFAULT: OFF // Test LED on startup parseJSON(GREEN); delay(300); parseJSON(RED); delay(300); parseJSON(BLUE); delay(300); parseJSON(WHITE); delay(300); parseJSON(OFF); delay(300); //Initialise bluetooth } void loop() { } //Parses JSON messages void parseJSON(char *payload) { char sel; // char json[200]; // payload.toCharArray(json, 50); StaticJsonBuffer<200> jsonBuffer; JsonObject& root = jsonBuffer.parseObject(payload); // Serial.print("DEBUG: "); Serial.println(json); if (!root.success()) { Serial.println("parseObject() failed"); return; } const char* device = root["device"]; const char* event = root["event"]; const char* color = root["color"]; if(strcmp(device, "LED") == 0) { if(strcmp(event, "on") == 0) { sel = color[0]; ledON(sel); } if (strcmp(event, "off") == 0) { ledOFF(); } } } // Turns the LED off void ledOFF(){ Bean.setLed(0, 0, 0); } // Turns on the LED on a specific color: r=red, g=gree, osv.. void ledON(char sel){ switch(sel) { case 'r': { Bean.setLed(255, 0, 0); Serial.println("DEBUG: LED RED ON"); break; } case 'g': { Bean.setLed(0, 255, 0); Serial.println("DEBUG: LED GREEN ON"); break; } case 'b': { Bean.setLed(0, 0, 255); Serial.println("DEBUG: LED BLUE ON"); break; } case 'w': { Bean.setLed(255, 255, 255); Serial.println("DEBUG: LED WITHE ON"); break; } }}
Add firmware for LightBlueBean Token
Add firmware for LightBlueBean Token
Arduino
unlicense
Matth26/anyboardjs,tomfa/anyboardjs,tomfa/anyboardjs
030b5c240977d05e5a83c9880277673af75d119a
Blink_ESP8266/Blink_ESP8266.ino
Blink_ESP8266/Blink_ESP8266.ino
/* * Blink for esp8266 */ #define ESP8266_LED 2 void setup() { // put your setup code here, to run once: pinMode(ESP8266_LED, OUTPUT); } void loop() { // put your main code here, to run repeatedly: digitalWrite(ESP8266_LED, HIGH); delay(1000); digitalWrite(ESP8266_LED, LOW); delay(1000); }
Add new sketch for ESP8266
Add new sketch for ESP8266
Arduino
cc0-1.0
darrell24015/Uno,darrell24015/Uno
6a3ef20f1f6e501e592f1163de973bddc629febd
examples/A01_ContrastHelper/A01_ContrastHelper.ino
examples/A01_ContrastHelper/A01_ContrastHelper.ino
/** Contrast Helper * * Loops through a range of contrast values and prints each one. * * To set the contrast in your sketch, simply put lcd.setContrast(xx); * after your lcd.begin(). * * Experimentally determined, contrast values around 65-70 tend to * work reasonably well on most displays. The best contrast value * for each display is specific to that particular display due to * manufacturing tolerances and so forth. * */ #include <SPI.h> #include "PCD8544_Simple.h" PCD8544_Simple lcd; const uint8_t contrastMin = 40; const uint8_t contrastMax = 80; static uint8_t contrastDirection = 1; static uint8_t contrast = (contrastMax-contrastMin)/2+contrastMin; void setup() { lcd.begin(); } void loop() { if(contrastDirection) { if(contrast++ > contrastMax) { contrastDirection = 0; } } else { if(contrast-- < contrastMin) { contrastDirection = 1; } } lcd.setContrast(contrast); lcd.print("lcd.setContrast("); lcd.print(contrast); lcd.println(");"); delay(500); }
Add example to help find suitable contrast value.
Add example to help find suitable contrast value.
Arduino
bsd-3-clause
sleemanj/PCD8544_Simple
3c0d6e4258c8ea5efb801627352e994240f550c6
Trigger.ino
Trigger.ino
// // Generate a 9Hz square signal to trigger camera and lightning // // Arduino setup void setup() { // Output signal pinMode( 13, OUTPUT ); } // Main loop void loop() { // High state (11ms) digitalWrite( 13, HIGH ); delay( 11 ); // Low state (100ms) digitalWrite( 13, LOW ); delay( 100 ); }
Add Arduino program to generate camera and light trigger.
Add Arduino program to generate camera and light trigger.
Arduino
mit
microy/PyStereoVisionToolkit,microy/PyStereoVisionToolkit,microy/StereoVision,microy/VisionToolkit,microy/StereoVision,microy/VisionToolkit
7324c5a8dbbbad438fc8a6f16a40bb1c7c1285e4
Arduino/motor_test/motor_test.ino
Arduino/motor_test/motor_test.ino
#include "DualVNH5019MotorShield.h" DualVNH5019MotorShield md; void stopIfFault() { if (md.getM1Fault()) { Serial.println("M1 fault"); while(1); } if (md.getM2Fault()) { Serial.println("M2 fault"); while(1); } } void setup() { Serial.begin(19200); Serial.println("Dual VNH5019 Motor Shield"); md.init(); } void loop() { for (int i = 0; i <= 400; i++) { md.setM1Speed(i); stopIfFault(); if (i%200 == 100) { Serial.print("M1 current: "); Serial.println(md.getM1CurrentMilliamps()); } delay(2); } for (int i = 400; i >= -400; i--) { md.setM1Speed(i); stopIfFault(); if (i%200 == 100) { Serial.print("M1 current: "); Serial.println(md.getM1CurrentMilliamps()); } delay(2); } for (int i = -400; i <= 0; i++) { md.setM1Speed(i); stopIfFault(); if (i%200 == 100) { Serial.print("M1 current: "); Serial.println(md.getM1CurrentMilliamps()); } delay(2); } for (int i = 0; i <= 400; i++) { md.setM2Speed(i); stopIfFault(); if (i%200 == 100) { Serial.print("M2 current: "); Serial.println(md.getM2CurrentMilliamps()); } delay(2); } for (int i = 400; i >= -400; i--) { md.setM2Speed(i); stopIfFault(); if (i%200 == 100) { Serial.print("M2 current: "); Serial.println(md.getM2CurrentMilliamps()); } delay(2); } for (int i = -400; i <= 0; i++) { md.setM2Speed(i); stopIfFault(); if (i%200 == 100) { Serial.print("M2 current: "); Serial.println(md.getM2CurrentMilliamps()); } delay(2); } }
Add test sketch which simply runs each motor separately, without input from Android
Add test sketch which simply runs each motor separately, without input from Android
Arduino
mit
zvikabh/RCCarController,zvikabh/RCCarController
65517b824630070a8ef5351a3f07c643de659be9
Sensors/GpsDataToSerial/GpsDataToSerial.ino
Sensors/GpsDataToSerial/GpsDataToSerial.ino
#include <SoftwareSerial.h> SoftwareSerial SoftSerial(2, 3); char buffer[265]; int count=0; void setup() { SoftSerial.begin(9600); Serial.begin(9600); } void loop() { if (SoftSerial.available()) { while(SoftSerial.available()) { buffer[count++]=SoftSerial.read(); if(count == 265)break; } String value = ""; if(String(char(buffer[0])) + char(buffer[1]) + char(buffer[2]) + char(buffer[3]) + char(buffer[4]) + char(buffer[5]) == "$GPGGA"){ boolean isEnd = false; int commaCount = 0; for(int i = 6; isEnd == false; i++){ if(buffer[i] == 44) commaCount++; if(commaCount == 14) isEnd = true; if(isEnd == true){ i -= 6; for(int x = 0; x <= i; x++){ char current = char(buffer[x]); value += current; } Serial.println(value); Serial.println(getValue(value,',',1)); Serial.println(getValue(value,',',2)); Serial.println(getValue(value,',',4)); } } } delay(1000); clearBufferArray(); count = 0; } } void clearBufferArray() { for (int i=0; i<count;i++) buffer[i]=NULL; } String getValue(String data, char separator, int index) { int found = 0; int strIndex[] = {0, -1}; int maxIndex = data.length()-1; for(int i=0; i<=maxIndex && found<=index; i++){ if(data.charAt(i)==separator || i==maxIndex){ found++; strIndex[0] = strIndex[1]+1; strIndex[1] = (i == maxIndex) ? i+1 : i; } } return found>index ? data.substring(strIndex[0], strIndex[1]) : ""; }
Read GPS data from sensor and write it to the serial port
Read GPS data from sensor and write it to the serial port
Arduino
apache-2.0
GillisWerrebrouck/SportModule,GillisWerrebrouck/SportModule
d85dc2215906d48c2c1a21a304d0f7c64e977037
jarbas.ino
jarbas.ino
#include <ESP8266HTTPClient.h> #include <ESP8266WiFiMulti.h> #define RELAY D1 const int HTTPS_PORT = 443; const char* WIFI = "WIFI"; const char* PASSWORD = "PASSWORD"; const char* HOST = "hooks.slack.com"; const char* URL = "URL"; String PAYLOAD = String("{\"text\": \"@here Café quentinho na cafeteira!\", \"link_names\": 1}"); ESP8266WiFiMulti wifi; bool turnOff = false; bool coffeeIsReady = false; void prepareCoffee() { delay(9 * 60 * 1000); // Wait 9 minutes. coffeeIsReady = true; } void notifySlack() { HTTPClient client; client.begin(HOST, HTTPS_PORT, URL, String("AC:95:5A:58:B8:4E:0B:CD:B3:97:D2:88:68:F5:CA:C1:0A:81:E3:6E")); client.addHeader("Content-Type", "application/x-www-form-urlencoded"); client.POST(PAYLOAD); client.end(); } void waitAndTurnOffCoffeeMachine() { delay(10 * 60 * 1000); // Wait 10 minutes. digitalWrite(RELAY, LOW); // Turn off. turnOff = true; } void setup() { wifi.addAP(WIFI, PASSWORD); pinMode(RELAY, OUTPUT); digitalWrite(RELAY, HIGH); } void loop() { if (!turnOff && !coffeeIsReady) prepareCoffee(); if (!turnOff && coffeeIsReady && wifi.run() == WL_CONNECTED) { notifySlack(); waitAndTurnOffCoffeeMachine(); } delay(1000); }
Add source code for Jarbas
Add source code for Jarbas
Arduino
mit
fablabjoinville/jarbas
40376ba1f0a6dede272df093181fd1d5697267f6
examples/ReadA0/ReadA0.ino
examples/ReadA0/ReadA0.ino
/* * Simple demonstration of AsyncDelay to read the A0 analogue input * every 50 ms. */ #include <AsyncDelay.h> AsyncDelay samplingInterval; void setup(void) { Serial.begin(115200); samplingInterval.start(50, AsyncDelay::MILLIS); } void loop(void) { if (samplingInterval.isExpired()) { uint16_t count = analogRead(A0); samplingInterval.repeat(); Serial.print(count); Serial.print('\n'); } }
Add example to read A0
Add example to read A0
Arduino
lgpl-2.1
stevemarple/AsyncDelay
6901dd15021ad107437aabf4441e49fd7adfa769
Arduino/libraries/UA_Sensors/examples/BasicUltrasonic/BasicUltrasonic.ino
Arduino/libraries/UA_Sensors/examples/BasicUltrasonic/BasicUltrasonic.ino
/* Test Ultrasonic sensor readings Created 2 7 2014 Modified 2 7 2014 */ // Ultrasonic sensor settings const byte ULTRASONIC_PIN = A6; void setup() { Serial.begin(9600); } void loop() { Serial.println(analogRead(ULTRASONIC_PIN)); delay(1000); }
Add simple sketch to test Ultrasonic sensor
Add simple sketch to test Ultrasonic sensor
Arduino
unlicense
UAA-EQLNES/EQLNES-Sensors
f44574108258d381336d02a6c52fd8bd3a7d3366
examples/Boards_BLE/Simblee_BLE/Simblee_BLE.ino
examples/Boards_BLE/Simblee_BLE/Simblee_BLE.ino
/************************************************************** * Blynk is a platform with iOS and Android apps to control * Arduino, Raspberry Pi and the likes over the Internet. * You can easily build graphic interfaces for all your * projects by simply dragging and dropping widgets. * * Downloads, docs, tutorials: http://www.blynk.cc * Blynk community: http://community.blynk.cc * Social networks: http://www.fb.com/blynkapp * http://twitter.com/blynk_app * * Blynk library is licensed under MIT license * This example code is in public domain. * ************************************************************** * * This example shows how to use Simblee BLE * to connect your project to Blynk. * * NOTE: BLE support is in beta! * **************************************************************/ //#define BLYNK_DEBUG #define BLYNK_PRINT Serial //#define BLYNK_USE_DIRECT_CONNECT #include <BlynkSimpleSimbleeBLE.h> #include <SimbleeBLE.h> char auth[] = "YourAuthToken"; void setup() { Serial.begin(9600); SimbleeBLE.deviceName = "Simblee"; SimbleeBLE.advertisementInterval = MILLISECONDS(300); SimbleeBLE.txPowerLevel = -20; // (-20dbM to +4 dBm) // start the BLE stack SimbleeBLE.begin(); Blynk.begin(auth); Serial.println("Bluetooth device active, waiting for connections..."); } void loop() { Blynk.run(); }
Add Simblee BLE example
Add Simblee BLE example [ci skip]
Arduino
mit
blynkkk/blynk-library,ivankravets/blynk-library,blynkkk/blynk-library,ivankravets/blynk-library,blynkkk/blynk-library,ivankravets/blynk-library,blynkkk/blynk-library,ivankravets/blynk-library,ivankravets/blynk-library,blynkkk/blynk-library
339a5cb2c9f41c451aa738678d23596ebe36cdea
examples/SerialCustom/SerialCustom.ino
examples/SerialCustom/SerialCustom.ino
#include "VdlkinoSerial.h" VdlkinoSerial vdlkino(14, 6, &Serial); uint16_t get_analog_byte(void *block) { VdlkinoBlock *vblock = (VdlkinoBlock*) block; return map(analogRead(vblock->pin), 0, 1023, 0, 255); } void setup() { Serial.begin(9600); vdlkino.operations[8] = &get_analog_byte; } void loop() { vdlkino.run(); }
Add example of a custom function in serial
Add example of a custom function in serial
Arduino
mit
eduardoklosowski/vdlkino,eduardoklosowski/vdlkino
27ec02189502418189737c8467935b6093d34165
examples/simple/simpleneopixelring.ino
examples/simple/simpleneopixelring.ino
/* NeoPixel Ring simple sketch (c) 2013 Shae Erisson released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library */ #include <Adafruit_NeoPixel.h> #ifdef __AVR_ATtiny85__ // Trinket, Gemma, etc. #include <avr/power.h> #endif // Which pin on the FLORA is connected to the NeoPixel ring? #define PIN 6 // We're using only one ring with 16 NeoPixel #define NUMPIXELS 16 // When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals. Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); int delayval = 500; // delay for half a second void setup() { #ifdef __AVR_ATtiny85__ // Trinket, Gemma, etc. if(F_CPU == 16000000) clock_prescale_set(clock_div_1); // Seed random number generator from an unused analog input: randomSeed(analogRead(2)); #else randomSeed(analogRead(A0)); #endif pixels.begin(); // This initializes the NeoPixel library. } void loop() { // for one ring of 16, the first NeoPixel is 0, second is 1, all the way up to 15 for(int i=0;i<NUMPIXELS;i++){ // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255 pixels.setPixelColor(i,pixels.Color(0,150,0)); // we choose green pixels.show(); // this sends the value once the color has been set delay(delayval); } }
Add a simple example sketch with many explanatory comments
Add a simple example sketch with many explanatory comments
Arduino
lgpl-2.1
gregersn/Adafruit_NeoPixel,gregersn/Adafruit_NeoPixel
cb034d2a626982f3c2f2e41294a71c96d9ed1398
AddAdmin_Payload/AddAdmin_Payload.ino
AddAdmin_Payload/AddAdmin_Payload.ino
#include <HID.h> #include <Keyboard.h> // Init function void setup() { // Start Keyboard and Mouse Keyboard.begin(); // Start Payload // press Windows+X Keyboard.press(KEY_LEFT_GUI); delay(1000); Keyboard.press('x'); Keyboard.releaseAll(); delay(500); // launch Command Prompt (Admin) typeKey('a'); delay(3000); // klik "Yes" typeKey(KEY_LEFT_ARROW); typeKey(KEY_RETURN); delay(1000); // add user Keyboard.println("net user /add Arduino 123456"); typeKey(KEY_RETURN); delay(100); // make that user become admin Keyboard.print("net localgroup administrators Arduino /add"); typeKey(KEY_RETURN); delay(100); Keyboard.print("exit"); typeKey(KEY_RETURN); // End Payload // Stop Keyboard and Mouse Keyboard.end(); } // Unused void loop() {} // Utility function void typeKey(int key){ Keyboard.press(key); delay(500); Keyboard.release(key); }
Add comment to improve code readability
Add comment to improve code readability
Arduino
mit
christofersimbar/ArduinoDuckyScript
e6cf01d5e12a6c4a7c563aa2a31e5feb54f879b0
ARTF_Sensors/examples/LowPowerUltrasonicWithSD/LowPowerUltrasonicWithSD.ino
ARTF_Sensors/examples/LowPowerUltrasonicWithSD/LowPowerUltrasonicWithSD.ino
/* Test Ultrasonic sensor readings on sensor platform This sketch is designed to test the accuracy of the Ultrasonic sensor with the battery pack and circuit of the sensor platform. This sketch takes 5 readings and averages them to help verify similar calculations used in BridgeSensorGSM sketch. The results are written to the SD card Created 10 7 2014 Modified 10 7 2014 */ #include <LowPower.h> #include <ARTF_SDCard.h> // ARTF SDCard Dependency #include <SdFat.h> #include <String.h> // Ultrasonic Settings const byte ULTRASONIC_PIN = A6; const int DISTANCE_INCREMENT = 5; const int NUM_READINGS = 5; // SD Card Settings const byte SD_CS_PIN = 10; #define OUTPUT_FILENAME "ultra.txt" ARTF_SDCard sd(SD_CS_PIN); void setup() { Serial.begin(9600); pinMode(SD_CS_PIN, OUTPUT); } int count = 1; void loop() { LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); String output = ""; output += "Trial " + String(count) + "\n"; output += "-------------------\n"; // Take X readings int distanceReadings[NUM_READINGS]; for (int i = 0; i < NUM_READINGS; ++i) { int reading = analogRead(ULTRASONIC_PIN); distanceReadings[i] = reading * DISTANCE_INCREMENT; output += String(i) + ". Analog:" + String(reading) + "; Calculated:" + String(distanceReadings[i]) + "\n"; delay(300); } // Average the readings double sumDistance = 0.0; for (int i = 0; i < NUM_READINGS; ++i) { sumDistance += distanceReadings[i]; } double avgDistance = sumDistance / NUM_READINGS; // Rounded measurements int roundedDistance = round(avgDistance); output += "Rounded:" + String(roundedDistance) + "\n\n"; sd.begin(); sd.writeFile(OUTPUT_FILENAME, output); delay(500); count += 1; }
Add sketch that test ultrasonic readings on sensor platform
Add sketch that test ultrasonic readings on sensor platform
Arduino
unlicense
UAA-EQLNES/ARTF-Field-Sensors
dd16ce7011543f55f699d0776c3d2068e961d5df
Arduino/robot_motor_body/robot_motor_body.ino
Arduino/robot_motor_body/robot_motor_body.ino
/* This is a test sketch for the Adafruit assembled Motor Shield for Arduino v2 It won't work with v1.x motor shields! Only for the v2's with built in PWM control For use with the Adafruit Motor Shield v2 ----> http://www.adafruit.com/products/1438 */ #include <Wire.h> #include <Adafruit_MotorShield.h> #include "utility/Adafruit_MS_PWMServoDriver.h" Adafruit_MotorShield AFMSbot(0x60); // Default address, no jumpers Adafruit_MotorShield AFMStop(0x61); // Rightmost jumper closed Adafruit_DCMotor *motorMiddleLeft = AFMStop.getMotor(2); //Backwards Adafruit_DCMotor *motorFrontLeft = AFMStop.getMotor(3); // Forwards Adafruit_DCMotor *motorBackLeft = AFMStop.getMotor(1); // Backwards Adafruit_DCMotor *motorBackRight = AFMSbot.getMotor(2); // Backwards Adafruit_DCMotor *motorFrontRight = AFMSbot.getMotor(3); // Backwards Adafruit_DCMotor *motorMiddleRight = AFMSbot.getMotor(4); // Backwards void setup() { while (!Serial); Serial.begin(9600); // set up Serial library at 9600 bps Serial.println("MMMMotor party!"); AFMSbot.begin(); // Start the bottom shield AFMStop.begin(); // Start the top shield // turn on the DC motor motorMiddleLeft->setSpeed(100); motorMiddleLeft->run(BACKWARD); motorFrontLeft->setSpeed(100); motorFrontLeft->run(FORWARD); motorBackLeft->setSpeed(100); motorBackLeft->run(BACKWARD); motorBackRight->setSpeed(100); motorBackRight->run(BACKWARD); motorFrontRight->setSpeed(100); motorFrontRight->run(BACKWARD); motorMiddleRight->setSpeed(100); motorMiddleRight->run(BACKWARD); } void loop() { }
Add initial robot motor body code
Add initial robot motor body code
Arduino
mit
johnflux/FluxRobot,johnflux/FluxRobot,johnflux/FluxRobot,johnflux/FluxRobot
93d9896f961d9cf2b4fe39ae93a75bba14a21a92
arduino/encoders_and_leds_test/encoders_and_leds_test.ino
arduino/encoders_and_leds_test/encoders_and_leds_test.ino
// Total number of input channels supported by the hardware const uint8_t numChannels = 5; const uint8_t ledPins[] = {2, 4, 7, 8, 12}; const uint8_t encoderPins[] = {5, 6, 9, 10, 11}; unsigned long currentEncoderValues[] = {0, 0, 0, 0, 0}; unsigned long previousEncoderValues[] = {0, 0, 0, 0, 0}; const unsigned long encoderValueThreshold = 2048; // Number of active parameters in the sketch const uint8_t numParams = 4; /* * Tests the LEDs and encoders. * If the encoder value is over a given threshold, the corresponding LED is lit. */ void setup() { Serial.begin(57600); for (uint8_t i = 0; i < numChannels; i++) { pinMode(ledPins[i], OUTPUT); pinMode(encoderPins[i], INPUT); } } void loop() { for (uint8_t i = 0; i < numParams; i++) { previousEncoderValues[i] = currentEncoderValues[i]; currentEncoderValues[i] = pulseIn(encoderPins[i], HIGH); Serial.print(currentEncoderValues[i]); if (i < numParams - 1) { Serial.print(" "); } if (currentEncoderValues[i] > encoderValueThreshold) { digitalWrite(ledPins[i], HIGH); } else { digitalWrite(ledPins[i], LOW); } } Serial.println(); }
Add Arduino sketch to test encoders and leds
Add Arduino sketch to test encoders and leds
Arduino
mit
sh0w/recoded,sh0w/recoded,sh0w/recoded,sh0w/recoded
d04b0c047011cdf3f6a02140d1c412b89265caff
tinkering/sensorboard/ADXL362_SimpleRead/ADXL362_SimpleRead.ino
tinkering/sensorboard/ADXL362_SimpleRead/ADXL362_SimpleRead.ino
/* ADXL362_SimpleRead.ino - Simple XYZ axis reading example for Analog Devices ADXL362 - Micropower 3-axis accelerometer go to http://www.analog.com/ADXL362 for datasheet License: CC BY-SA 3.0: Creative Commons Share-alike 3.0. Feel free to use and abuse this code however you'd like. If you find it useful please attribute, and SHARE-ALIKE! Created June 2012 by Anne Mahaffey - hosted on http://annem.github.com/ADXL362 Modified May 2013 by Jonathan Ruiz de Garibay Connect SCLK, MISO, MOSI, and CSB of ADXL362 to SCLK, MISO, MOSI, and DP 10 of Arduino (check http://arduino.cc/en/Reference/SPI for details) */ #include <SPI.h> #include <ADXL362.h> ADXL362 xl; int16_t temp; int16_t XValue, YValue, ZValue, Temperature; void setup(){ Serial.begin(9600); xl.begin(10); // Setup SPI protocol, issue device soft reset xl.beginMeasure(); // Switch ADXL362 to measure mode Serial.println("Start Demo: Simple Read"); } void loop(){ // read all three axis in burst to ensure all measurements correspond to same sample time xl.readXYZTData(XValue, YValue, ZValue, Temperature); Serial.print("XVALUE="); Serial.print(XValue); Serial.print("\tYVALUE="); Serial.print(YValue); Serial.print("\tZVALUE="); Serial.print(ZValue); Serial.print("\tTEMPERATURE="); Serial.println(Temperature); delay(100); // Arbitrary delay to make serial monitor easier to observe }
Test for accelerometer on sensorboard.
Test for accelerometer on sensorboard.
Arduino
mit
fkmclane/derailleurs,fkmclane/derailleurs,fkmclane/derailleurs
82fe8883c42a5df36a1b79b4ba918049b14a4e30
projects/C7C.Atamo.Dusty.Mote_0_0_2/resources/Testing/TU_SH_DpUart_external_op.ino
projects/C7C.Atamo.Dusty.Mote_0_0_2/resources/Testing/TU_SH_DpUart_external_op.ino
#include <SoftwareSerial.h> // software serial #2: RX = digital pin 8, TX = digital pin 9 // on the Mega, use other pins instead, since 8 and 9 don't work on the Mega SoftwareSerial portTwo(8, 9); void setup() { pinMode(LED_BUILTIN, OUTPUT); // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } // Start each software serial portm portTwo.begin(9600); digitalWrite(LED_BUILTIN, LOW); } void loop() { // Now listen on the second port portTwo.listen(); // while there is data coming in, read it // and send to the hardware serial port: Serial.println("Data from port two:"); while (portTwo.available() > 0) { char inByte = portTwo.read(); delay(500); Serial.write(inByte); } }
Add project resources for Mote
Add project resources for Mote Project resources ships external build files required (primarily for testing)
Arduino
mit
CloudSevenConsulting/DustyDuinoPro,CloudSevenConsulting/DustyDuinoPro
41105eb3e799b2cc65f084c8625ab7ca43fe975a
HBridgePWM/Sabertooth/Sabertooth.ino
HBridgePWM/Sabertooth/Sabertooth.ino
// Software Serial Sample // Copyright (c) 2012 Dimension Engineering LLC // See license.txt for license details. #include <SoftwareSerial.h> #include <SabertoothSimplified.h> SoftwareSerial SWSerial(NOT_A_PIN, 11); // RX on no pin (unused), TX on pin 11 (to S1). SabertoothSimplified ST(SWSerial); // Use SWSerial as the serial port. void setup() { SWSerial.begin(9600); } void loop() { int power; // Ramp from -127 to 127 (full reverse to full forward), waiting 20 ms (1/50th of a second) per value. for (power = -127; power <= 127; power ++) { ST.motor(1, power); delay(20); } // Now go back the way we came. for (power = 127; power >= -127; power --) { ST.motor(1, power); delay(20); } }
Add a file to control sabertooth board
Add a file to control sabertooth board
Arduino
mit
baptistelabat/robokite,baptistelabat/robokite,baptistelabat/robokite,baptistelabat/robokite,baptistelabat/robokite,baptistelabat/robokite,baptistelabat/robokite,baptistelabat/robokite
6c56abd028f6b66d9a8f1333292a01ed96dd4bd7
examples/temp_sensor/temp_sensor.ino
examples/temp_sensor/temp_sensor.ino
// TimerOne library: https://code.google.com/p/arduino-timerone/ #include <TimerOne.h> #include <SPI.h> #include <BLEPeripheral.h> // define pins (varies per shield/board) #define BLE_REQ 10 #define BLE_RDY 2 #define BLE_RST 9 BLEPeripheral blePeripheral = BLEPeripheral(BLE_REQ, BLE_RDY, BLE_RST); BLEService tempService = BLEService("CCC0"); BLEIntCharacteristic tempCharacteristic = BLEIntCharacteristic("CCC1", BLERead | BLENotify); BLEDescriptor tempDescriptor = BLEDescriptor("2901", "Celsius"); volatile bool readTemperature = false; void setup() { Serial.begin(115200); #if defined (__AVR_ATmega32U4__) //Wait until the serial port is available (useful only for the Leonardo) //As the Leonardo board is not reseted every time you open the Serial Monitor while(!Serial) {} delay(5000); //5 seconds delay for enabling to see the start up comments on the serial board #endif blePeripheral.setLocalName("Temperature"); blePeripheral.setAdvertisedServiceUuid(tempService.uuid()); blePeripheral.addAttribute(tempService); blePeripheral.addAttribute(tempCharacteristic); blePeripheral.addAttribute(tempDescriptor); blePeripheral.setEventHandler(BLEConnected, blePeripheralConnectHandler); blePeripheral.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler); blePeripheral.begin(); Timer1.initialize(1 * 1000000); // in milliseconds Timer1.attachInterrupt(timerHandler); } void loop() { blePeripheral.poll(); if (readTemperature) { setTempCharacteristicValue(); readTemperature = false; } } void timerHandler() { readTemperature = true; } void setTempCharacteristicValue() { int temp = readTempC(); tempCharacteristic.setValue(temp); Serial.println(temp); } int readTempC() { // Stubbing out for demo with random value generator // Replace with actual sensor reading code return random(100); } void blePeripheralConnectHandler(BLECentral& central) { Serial.print(F("Connected event, central: ")); Serial.println(central.address()); } void blePeripheralDisconnectHandler(BLECentral& central) { Serial.print(F("Disconnected event, central: ")); Serial.println(central.address()); }
Add temp sensor example sketch
Add temp sensor example sketch
Arduino
mit
sandeepmistry/arduino-BLEPeripheral,femtoduino/arduino-BLEPeripheral,sandeepmistry/arduino-BLEPeripheral,sandeepmistry/arduino-BLEPeripheral,pi19404/arduino-BLEPeripheral,possan/arduino-BLEPeripheral,femtoduino/arduino-BLEPeripheral,possan/arduino-BLEPeripheral,pi19404/arduino-BLEPeripheral
08bccef6e71d1815f63c743dec8c72d02ddb842c
sketches/tests/sched_blinksda/sched_blinksda.ino
sketches/tests/sched_blinksda/sched_blinksda.ino
/** * Use the schedule class to have two different LEDs on one JeeNode * port flash at different rates. One LED is on DIO and the other * AIO. * * This is a straight-forward modification of the sched_blinks.ino * sketch. * * Based largely on jcw's "schedule" and "blink_ports" sketches * * Changes: * - remove BlinkPlug specifics but use the same techniques. The * LEDs are wired between DIO/AIO and GND rather than VCC and * DIO/AIO as in the BlinkPlug code. * * Original "blink_ports" sketch: * 2009-02-13 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php * Original "schedule" sketch: * 2010-10-18 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php * Modifications * 2015-08-14 <bill@jamimi.com> http://opensource.org/licenses/mit-license.php */ #include <JeeLib.h> Port one (4); // Connect a series resistor (470 or 1k ohm) to two leds. Connect one // to pins 2 (DIO) and 3 (GND) on Jeenode port 4 and the other to pins // 5 (AIO) and 3 (GND). enum { TASK1, TASK2, TASK_LIMIT }; static word schedBuf[TASK_LIMIT]; Scheduler scheduler (schedBuf, TASK_LIMIT); byte led1, led2; // this has to be added since we're using the watchdog for low-power waiting ISR(WDT_vect) { Sleepy::watchdogEvent(); } void setup () { Serial.begin(57600); Serial.println("\n[schedule]"); Serial.flush(); // turn the radio off completely rf12_initialize(17, RF12_868MHZ); rf12_sleep(RF12_SLEEP); one.mode(OUTPUT); one.mode2(OUTPUT); led1 = 0; led2 = 0; // start both tasks 1.5 seconds from now scheduler.timer(TASK1, 15); scheduler.timer(TASK2, 15); } void loop () { switch (scheduler.pollWaiting()) { // LED 1 blinks .1 second every second case TASK1: led1 = !led1; if (led1) { one.digiWrite(1); scheduler.timer(TASK1, 1); } else { one.digiWrite(0); scheduler.timer(TASK1, 8); } break; // LED 2 blinks .5 second every second case TASK2: led2 = !led2; if (led2) { one.digiWrite2(1); scheduler.timer(TASK2, 1); } else { one.digiWrite2(0); scheduler.timer(TASK2, 3); } break; } }
Test script for flashing LEDs on same port using AIO and DIO
Test script for flashing LEDs on same port using AIO and DIO
Arduino
mit
wmadill/grant-lighting,wmadill/grant-lighting
4893315b91d9167143a83e7e5bd464ac7c0846d6
examples/HIH61xx_SoftWire_simple_demo/HIH61xx_SoftWire_simple_demo.ino
examples/HIH61xx_SoftWire_simple_demo/HIH61xx_SoftWire_simple_demo.ino
// This example demonstrates how to use the HIH61xx class with the SoftWire library. SoftWire is a software I2C // implementation which enables any two unused pins to be used as a I2C bus. A blocking read is made to the // HIH61xx device. See HIH61xx_SoftWire_demo for a more sophisticated example which allows other tasks to run // whilst the HIH61xx takes its measurements. #include <SoftWire.h> #include <HIH61xx.h> #include <AsyncDelay.h> // Create an instance of the SoftWire class called "sw". In this example it uses the same pins as the hardware I2C // bus. Pass the pin numbers to use different pins. SoftWire sw(SDA, SCL); // The "hih" object must be created with a reference to the SoftWire "sw" object which represents the I2C bus it is // using. Note that the class for the SoftWire object must be included in the templated class name. HIH61xx<SoftWire> hih(sw); AsyncDelay samplingInterval; // SoftWire requires that the programmer declares the buffers used. This allows the amount of memory used to be set // according to need. For the HIH61xx only a very small RX buffer is needed. uint8_t i2cRxBuffer[4]; uint8_t i2cTxBuffer[32]; void setup(void) { #if F_CPU >= 12000000UL Serial.begin(115200); #else Serial.begin(9600); #endif // The pin numbers for SDA/SCL can be overridden at runtime. // sw.setSda(sdaPin); // sw.setScl(sclPin); sw.setRxBuffer(i2cRxBuffer, sizeof(i2cRxBuffer)); //sw.setTxBuffer(i2cTxBuffer, sizeof(i2cTxBuffer)); // HIH61xx doesn't need a TX buffer at all but other I2C devices probably will. //sw.setTxBuffer(i2cTxBuffer, sizeof(i2cTxBuffer)); sw.setTxBuffer(NULL, 0); sw.begin(); // Sets up pin mode for SDA and SCL hih.initialise(); samplingInterval.start(3000, AsyncDelay::MILLIS); } void loop(void) { // Instruct the HIH61xx to take a measurement. This blocks until the measurement is ready. hih.read(); // Fetch and print the results Serial.print("Relative humidity: "); Serial.print(hih.getRelHumidity() / 100.0); Serial.println(" %"); Serial.print("Ambient temperature: "); Serial.print(hih.getAmbientTemp() / 100.0); Serial.println(" deg C"); Serial.print("Status: "); Serial.println(hih.getStatus()); // Wait a second delay(1000); }
Add example demonstrating the simple `read()` command and SoftWire
Add example demonstrating the simple `read()` command and SoftWire
Arduino
lgpl-2.1
stevemarple/HIH61xx
fa23210d8cc415f507c6f1c78b958dcc854081d5
arduino/tests/tests/tests.ino
arduino/tests/tests/tests.ino
/* * User testing for the arduino * Two kinds of messages can be send to the arduino: * - 0-255 * - S,1,# * c rrrgggbbb * - L,1,C#########\n */ void setup() { // put your setup code here, to run once: Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: } // Serial event gets called when anything in the serial happens. void serialEvent() { String s = ""; while(Serial.available()) { char c = (char)Serial.read(); s += c; if (c == '\n') { Serial.print(s); } } }
Test for checking the processing code
Test for checking the processing code
Arduino
mit
PeterVerzijl/TableOfContinents,TonyTonijn/TableOfContinents,TonyTonijn/TableOfContinents,PeterVerzijl/TableOfContinents
d0c074e481e43fbc6bfbf1b80843a34f6bd3fce9
CurieIMU/CurieIMU.ino
CurieIMU/CurieIMU.ino
#include "CurieIMU.h" void setup() { Serial.begin(9600); // Initialize internal IMU CurieIMU.begin(); // Set accelerometer range to 2G CurieIMU.setAccelerometerRange(2); } void loop() { float ax, ay, az; CurieIMU.readAccelerometerScaled(ax, ay, az); Serial.print("Value ax:"); Serial.print(ax); Serial.print(" / ay:"); Serial.print(ay); Serial.print(" / az:"); Serial.println(az); delay(100); }
Implement IMU unit on Curie
Implement IMU unit on Curie
Arduino
mit
niccolli/WebBluetoothAPIwithCURIE
95a56ce4185f2863b98403ee4e6875de1c27e374
examples/Widgets/LED/LED_Color/LED_Color.ino
examples/Widgets/LED/LED_Color/LED_Color.ino
/************************************************************** * Blynk is a platform with iOS and Android apps to control * Arduino, Raspberry Pi and the likes over the Internet. * You can easily build graphic interfaces for all your * projects by simply dragging and dropping widgets. * * Downloads, docs, tutorials: http://www.blynk.cc * Blynk community: http://community.blynk.cc * Social networks: http://www.fb.com/blynkapp * http://twitter.com/blynk_app * * Blynk library is licensed under MIT license * This example code is in public domain. * ************************************************************** * Blynk using a LED widget on your phone! * * App project setup: * LED widget on V1 * * WARNING : * For this example you'll need SimpleTimer library: * https://github.com/jfturcot/SimpleTimer * Visit this page for more information: * http://playground.arduino.cc/Code/SimpleTimer * **************************************************************/ #define BLYNK_PRINT Serial // Comment this out to disable prints and save space #include <SPI.h> #include <Ethernet.h> #include <BlynkSimpleEthernet.h> #include <SimpleTimer.h> // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "YourAuthToken"; WidgetLED led1(V1); SimpleTimer timer; #define BLYNK_GREEN "#23C48E" #define BLYNK_BLUE "#04C0F8" #define BLYNK_YELLOW "#ED9D00" #define BLYNK_RED "#D3435C" #define BLYNK_DARK_BLUE "#5F7CD8" void setup() { Serial.begin(9600); // See the connection status in Serial Monitor Blynk.begin(auth); timer.setInterval(1000L, blinkLedWidget); } // V1 LED Widget is blinking void blinkLedWidget() { if (led1.getValue()) { led1.setColor(BLYNK_RED); Serial.println("LED on V1: red"); } else { led1.setColor(BLYNK_GREEN); Serial.println("LED on V1: green"); } } void loop() { Blynk.run(); timer.run(); }
Add LED widget setColor example
Add LED widget setColor example
Arduino
mit
blynkkk/blynk-library,blynkkk/blynk-library,ivankravets/blynk-library,ivankravets/blynk-library,ivankravets/blynk-library,ivankravets/blynk-library,blynkkk/blynk-library,ivankravets/blynk-library,blynkkk/blynk-library,blynkkk/blynk-library
a75dbb9357a831bf6046bbe55fd779cfcca697f1
examples/mbino-example-spi-25lc040/mbino-example-spi-25lc040.ino
examples/mbino-example-spi-25lc040/mbino-example-spi-25lc040.ino
#include "mbed.h" // use fully qualified class name to resolve ambiguities with // Arduino's own global "SPI" object mbed::SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK); DigitalOut cs(D10); RawSerial pc(USBTX, USBRX); static const uint8_t READ = 0x03; // read data from memory array static const uint8_t WRITE = 0x02; // write data to memory array static const uint8_t WRDI = 0x04; // disable write operations static const uint8_t WREN = 0x06; // enable write operations static const uint8_t RDSR = 0x05; // read STATUS register static const uint8_t WRSR = 0x01; // write STATUS register uint16_t address = 0; // 0..511 void setup() { // Chip must be deselected cs = 1; // Setup the spi for 8 bit data, high steady state clock, second // edge capture, with a 1MHz clock rate spi.format(8, 0); spi.set_default_write_value(0); } void loop() { const char tx_buffer[16] = "0123456789ABCDEF"; char rx_buffer[16]; pc.printf("write @0x%03x: %.16s\r\n", address, tx_buffer); cs = 0; wait_ms(1); spi.write(WREN); spi.write(0); wait_ms(1); cs = 1; wait_ms(1); cs = 0; wait_ms(1); spi.write(WRITE | ((address & 0x100) >> 5)); spi.write(address & 0xff); spi.write(tx_buffer, sizeof tx_buffer, 0, 0); wait_ms(1); cs = 1; wait_ms(1); cs = 0; wait_ms(1); spi.write(READ | ((address & 0x100) >> 5)); spi.write(address & 0xff); spi.write(0, 0, rx_buffer, sizeof rx_buffer); wait_ms(1); cs = 1; pc.printf("read @0x%03x: %.16s\r\n", address, rx_buffer); address += 16; address %= 512; wait(1); } #ifndef ARDUINO int main() { setup(); for (;;) { loop(); } } #endif
Add SPI EEPROM 25LC040 example.
Add SPI EEPROM 25LC040 example.
Arduino
apache-2.0
tkem/mbino,tkem/mbino,tkem/mbino
e22998424748a7125b73e152ab7ad301f0ed248b
examples/OneShotExample/OneShotExample.ino
examples/OneShotExample/OneShotExample.ino
#include <AsyncDelay.h> AsyncDelay oneShot; bool messagePrinted = false; void setup(void) { Serial.begin(9600); Serial.println("Starting one-shot timer"); oneShot.start(5000, AsyncDelay::MILLIS); } void loop(void) { if (!messagePrinted && oneShot.isExpired()) { Serial.print("The timer was started "); Serial.print(oneShot.getDelay()); if (oneShot.getUnit() == AsyncDelay::MILLIS) Serial.println(" ms ago"); else Serial.println(" us ago"); messagePrinted = true; // Print the message just once oneShot = AsyncDelay(); } }
Add example showing one-shot usage
Add example showing one-shot usage
Arduino
lgpl-2.1
stevemarple/AsyncDelay
9c47fcfc3969b53d20166d1df0c6615bbe4abee7
arduino/LidarServo/LidarServo.ino
arduino/LidarServo/LidarServo.ino
#include <I2C.h> #include <Servo.h> #define LIDARLite_ADDRESS 0x62 // Default I2C Address of LIDAR-Lite. #define RegisterMeasure 0x00 // Register to write to initiate ranging. #define MeasureValue 0x04 // Value to initiate ranging. #define RegisterHighLowB 0x8f // Register to get both High and Low bytes in 1 call. Servo myservo; int pos = 0; int range = 0; int STARTANGLE = 45; int ENDANGLE = 135; void setup() { Serial.begin(9600); //Opens serial connection at 9600bps. I2c.begin(); // Opens & joins the irc bus as master delay(100); // Waits to make sure everything is powered up before sending or receiving data I2c.timeOut(50); // Sets a timeout to ensure no locking up of sketch if I2C communication fails myservo.attach(13); } int getLidarRange(){ // Write 0x04 to register 0x00 uint8_t nackack = 100; // Setup variable to hold ACK/NACK resopnses while (nackack != 0) { // While NACK keep going (i.e. continue polling until sucess message (ACK) is received ) nackack = I2c.write(LIDARLite_ADDRESS, RegisterMeasure, MeasureValue); // Write 0x04 to 0x00 delay(1); // Wait 1 ms to prevent overpolling } byte distanceArray[2]; // array to store distance bytes from read function // Read 2byte distance from register 0x8f nackack = 100; // Setup variable to hold ACK/NACK resopnses while (nackack != 0) { // While NACK keep going (i.e. continue polling until sucess message (ACK) is received ) nackack = I2c.read(LIDARLite_ADDRESS, RegisterHighLowB, 2, distanceArray); // Read 2 Bytes from LIDAR-Lite Address and store in array delay(1); // Wait 1 ms to prevent overpolling } int distance = (distanceArray[0] << 8) + distanceArray[1]; // Shift high byte [0] 8 to the left and add low byte [1] to create 16-bit int return distance; } void spinAndScan(int pos){ // move servo to position myservo.write(pos); //scan and print distance range = getLidarRange(); Serial.print("range: "); Serial.print(range); Serial.print(" pos: "); Serial.println(pos - 90); } void loop() { for(pos = STARTANGLE; pos < ENDANGLE; pos += 1){ spinAndScan(pos); } for(pos = ENDANGLE; pos>=STARTANGLE; pos-=1){ spinAndScan(pos); } }
Add arduino Lidar and servo sweeping code
Add arduino Lidar and servo sweeping code
Arduino
mit
Erik-J-D/SYDE361-AutomotiveIOT-PhoneApp-Sensors,Erik-J-D/SYDE361-AutomotiveIOT-PhoneApp-Sensors,Erik-J-D/SYDE361-AutomotiveIOT-PhoneApp-Sensors,Erik-J-D/SYDE361-AutomotiveIOT-PhoneApp-Sensors,Erik-J-D/SYDE361-AutomotiveIOT-PhoneApp-Sensors
21e972aa2a1971db29fca916189718d65921e80d
BlinkAttiny85/BlinkAttiny85.ino
BlinkAttiny85/BlinkAttiny85.ino
/* Blink Turns on an LED on for one second, then off for one second, repeatedly. This example code is in the public domain. */ // Pin 13 has an LED connected on most Arduino boards. // give it a name: int led = 3; int led2 = 4; // the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. pinMode(led, OUTPUT); pinMode(led2, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(led, HIGH); digitalWrite(led2, LOW); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); digitalWrite(led2, HIGH); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }
Add blink test for Attiny85
Add blink test for Attiny85 test OK with new core arduino-tiny
Arduino
mit
totothekiller/weather-station,totothekiller/weather-station
587706b8496205d89585c1e5bd547f824d363386
arduino/2x2x2-cube.ino
arduino/2x2x2-cube.ino
#define REP(x,n) for(int x=0;x<n;x++) #define ALL REP(i,2) REP(j,2) REP(k,2) const int DELAY = 10; int cube[2][2][2]; int cols[2][2] = {{8, 9}, {10, 11}}; int rows[2] = {6, 7}; void clear() { ALL cube[i][j][k] = 0; } void setup() { REP(i,2) pinMode(rows[i], OUTPUT); REP(i,2) REP(j,2) pinMode(cols[i][j], OUTPUT); } void randomIn(int time) { int count = 8; while(count > 0){ int x = random(2); int y = random(2); int z = random(2); if(cube[y][x][z]==0){ cube[y][x][z]=1; count--; show(time); } } } void layerSpiral(int i, int time) { REP(j,2) { cube[i][0][j] = 1; show(time); clear(); } REP(j,2) { cube[i][1][1-j] = 1; show(time); clear(); } } void layer(int i, int time) { REP(j,2) REP(k,2) cube[i][j][k] = 1; show(time); clear(); } void loop() { const int t = 100; REP(x,4) REP(l,2){ layer(l, 500); } REP(x,3) ALL { cube[i][j][k] = 1; show(t); clear(); } REP(x,3){ randomIn(t); clear(); } REP(i,3){ REP(l,2){ REP(x,3) layerSpiral(l, t); } } } void show(int time){ REP(t,time/DELAY/2){ REP(i,2){ digitalWrite(rows[i], LOW); REP(j,2) REP(k,2){ digitalWrite(cols[j][k], cube[i][j][k] ? HIGH : LOW); } delay(DELAY); digitalWrite(rows[i], HIGH); } } }
Add simple demo stuff for 2x2x2 cube
Add simple demo stuff for 2x2x2 cube
Arduino
mit
neojski/random,neojski/random,neojski/random,neojski/random,neojski/random,neojski/random,neojski/random,neojski/random
d942f251f7e7b92f11bb4f699e819384a4b178fa
serial/teensy32-throughput/teensy32-throughput.ino
serial/teensy32-throughput/teensy32-throughput.ino
//#define USE_BINARY const int sampleRate = 8000; const long serialRate = 2000000; const int NWORDS = 20; const int WSIZE = sizeof(uint16_t); const int NBYTES = NWORDS * WSIZE; volatile bool pushData = false; typedef union { uint16_t words[NWORDS]; uint8_t bytes[NBYTES]; } MODEL; MODEL m; IntervalTimer myTimer; void setup(void) { for (int i = 0; i < NWORDS; i++) m.words[i] = i+1000; pinMode(LED_BUILTIN, OUTPUT); SerialUSB.begin(serialRate); myTimer.begin(blinkLED, 1000000 / sampleRate); } void blinkLED(void) { pushData = true; } void loop(void) { static int counter = 0; bool state = (counter++ >> 12) % 2; digitalWrite(LED_BUILTIN, state ? HIGH : LOW); if (pushData) { pushData = false; #ifdef USE_BINARY SerialUSB.write(m.bytes, NBYTES); #else for (int i = 0; i < NWORDS; i++) { if (i!=0) SerialUSB.print('\t'); SerialUSB.print(m.words[i], DEC); } #endif SerialUSB.write('\n'); } }
Add simple teensy throughput program
Add simple teensy throughput program
Arduino
mit
isaias-b/arduino-examples,isaias-b/arduino-examples,isaias-b/arduino-examples
86f90a45c5de27a9f4838a20de9e94fc731e8406
arduino/uno/003_blinky_with_timer1_compa/003_blinky_with_timer1_compa.ino
arduino/uno/003_blinky_with_timer1_compa/003_blinky_with_timer1_compa.ino
/** * Copyright (c) 2019, Łukasz Marcin Podkalicki <lpodkalicki@gmail.com> * ArduinoUno/003 * Blinky with Timer1 COMPA. */ #define LED_PIN (13) void setup() { pinMode(LED_PIN, OUTPUT); // set LED pin as output TCCR1A = 0; // clear register TCCR1B = _BV(WGM12); // set Timer1 to CTC mode TCCR1B |= _BV(CS12)|_BV(CS10); // set Timer1 prescaler to 1024 TIMSK1 |= _BV(OCIE1A); // enable Timer1 COMPA interrupt OCR1A = 7812; // set value for Fx=1Hz, OCRnx = (16Mhz/(Fx * 2 * 1024) + 1) interrupts(); // enable global interrupts } void loop() { // do nothing } ISR(TIMER1_COMPA_vect) { digitalWrite(LED_PIN, !digitalRead(LED_PIN)); // Toggle LED pin }
Add next Arduino example - blinky with Timer1 COMPA.
Add next Arduino example - blinky with Timer1 COMPA.
Arduino
bsd-3-clause
lpodkalicki/blog,lpodkalicki/blog,lpodkalicki/blog,lpodkalicki/blog,lpodkalicki/blog,lpodkalicki/blog
6f9b8eb1b970ff4223cd143733a12d5f4294f062
arduino/uno/001_blinky_with_delay_function/001_blinky_with_delay_function.ino
arduino/uno/001_blinky_with_delay_function/001_blinky_with_delay_function.ino
/** * Copyright (c) 2019, Łukasz Marcin Podkalicki <lpodkalicki@gmail.com> * ArduinoUno/001 * Blinky with delay function. */ #define LED_PIN (13) void setup() { pinMode(LED_PIN, OUTPUT); } void loop() { digitalWrite(LED_PIN, !digitalRead(LED_PIN)); // Toggle LED pin delay(500); // wait 0.5s }
Add first Arduino example - blinky with delay function.
Add first Arduino example - blinky with delay function.
Arduino
bsd-3-clause
lpodkalicki/blog,lpodkalicki/blog,lpodkalicki/blog,lpodkalicki/blog,lpodkalicki/blog,lpodkalicki/blog
774b7cd6ac943d58d843d3f99bf757de5cd7eeaf
temp_and_light_lcd/temp_and_light_lcd.ino
temp_and_light_lcd/temp_and_light_lcd.ino
/* * Read temperature and light and display on the LCD * * For: Arduino Uno R3 * * Parts: * 1x LCD (16x2 characters) * 1x 10 kΩ variable resistor * 1x 10 KΩ resistor * 1x 220 Ω resitor * 1x Photocell * 1x TMP36 temperature sensor */ #include <LiquidCrystal.h> int temperaturePin = 0; int lightPin = 1; LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { // Set columns and rows to use lcd.begin(16, 2); // Start on the first row lcd.print("Temp : C"); } void loop() { int temperatureReading = analogRead(temperaturePin); float temperatureInVolts = (temperatureReading / 1024.0) * 5.0; float temperatureInCelcius = (temperatureInVolts - 0.5) * 100; // Jump 6 columns lcd.setCursor(6, 0); lcd.print(temperatureInCelcius); int lightReading = analogRead(lightPin); // Jump to the next row lcd.setCursor(0, 1); lcd.print("Light: "); lcd.setCursor(6, 1); lcd.print(lightReading); delay(1000); }
Add code to read temperature and light to display on a LCD
Add code to read temperature and light to display on a LCD
Arduino
unlicense
pads/arduino-learning
2b8d74e66aa716e945a0e7e000ed67697aed2980
ARTF_Sensors/examples/LowPowerMoistureWithSD/LowPowerMoistureWithSD.ino
ARTF_Sensors/examples/LowPowerMoistureWithSD/LowPowerMoistureWithSD.ino
/* Test Moisture sensor readings on sensor platform This sketch is designed to test the accuracy of the Moisture sensor with the battery pack and circuit of the sensor platform. This sketch takes 5 readings and averages them to help verify similar calculations used in MoistureSensorGSM sketch. The results are written to the SD card Created 10 7 2014 Modified 10 7 2014 */ #include <LowPower.h> #include <ARTF_SDCard.h> // ARTF SDCard Dependency #include <SdFat.h> #include <String.h> // Moisture sensor settings const byte MOISTURE_PIN = A6; const byte MOSFET_MS_PIN = 5; const int NUM_READINGS = 5; const int MOISTURE_MAX_READING = 600; // SD Card Settings const byte SD_CS_PIN = 10; #define OUTPUT_FILENAME "ultra.txt" ARTF_SDCard sd(SD_CS_PIN); void setup() { Serial.begin(9600); pinMode(SD_CS_PIN, OUTPUT); } int count = 1; void loop() { LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); String output = ""; output += "Trial " + String(count) + "\n"; output += "-------------------\n"; digitalWrite(MOSFET_MS_PIN, HIGH); delay(3000); // Take X readings int moistureReadings[NUM_READINGS]; for (int i = 0; i < NUM_READINGS; ++i) { int reading = analogRead(MOISTURE_PIN); moistureReadings[i] = (double)reading / (double)MOISTURE_MAX_READING; output += String(i) + ". Analog:" + String(reading) + "; Calculated:" + String(moistureReadings[i]) + "\n"; delay(300); } digitalWrite(MOSFET_MS_PIN, LOW); delay(500); // Average the readings double sumMoisture = 0.0; for (int i = 0; i < NUM_READINGS; ++i) { sumMoisture += moistureReadings[i]; } double avgMoisture = sumMoisture / NUM_READINGS; // Rounded measurements int roundedMoisture = round(avgMoisture * 100); output += "Rounded:" + String(roundedMoisture) + "\n\n"; sd.begin(); sd.writeFile(OUTPUT_FILENAME, output); delay(500); count += 1; }
Add test sketch for moisture sensor and sd card on kit
Add test sketch for moisture sensor and sd card on kit
Arduino
unlicense
UAA-EQLNES/ARTF-Field-Sensors
712e28a1166ffac7ffea7f677a4364abbbe79a58
pseudoRandom_Demo/pseudoRandom_Demo.ino
pseudoRandom_Demo/pseudoRandom_Demo.ino
/* * pseudoRandom Demonstration sketch * Author: Darrell Little * Date: 04/29/2017 * This code is in the public domain */ // Array to hold the pin numbers with LED connected int ledPin[] = {11,10,9,6}; // Variable to set the delay time to blink int waitTime = 1000; // Variable to hold the random LED pin to blink int randomLED; void setup() { // put your setup code here, to run once: // Use reading on Analog pin 0 for a randon seed randomSeed(analogRead(0)); // Initialize each pin in array to Output and Low (off) for (int x=0; x<4; x++) { pinMode(ledPin[x], OUTPUT); digitalWrite(ledPin[x], LOW); } } void loop() { // put your main code here, to run repeatedly: // Randomly select a LED pin number randomLED = random(0,4); // Turn LED on digitalWrite(ledPin[randomLED], HIGH); delay(waitTime); // Turn LED off digitalWrite(ledPin[randomLED], LOW); delay(waitTime); }
Add pseudoRandom Demo for Science Museum project
Add pseudoRandom Demo for Science Museum project
Arduino
cc0-1.0
darrell24015/Uno,darrell24015/Uno
a9e787693034e5b3a647ba2a24bab9d8ca5d24b9
Calibration/sdWrite/sdWrite.ino
Calibration/sdWrite/sdWrite.ino
#include <SD.h> #include <SPI.h> void setup() { //this is needed for the duemilanove and uno without ethernet shield const int sdCardPin = 10; int loopCount = 0; //for testing. delete before launches. Serial.begin(9600); delay(1000); pinMode(10,OUTPUT); if (!SD.begin(sdCardPin)) { Serial.println("Card failed, or not present"); // don't do anything more: return; } Serial.println("card initialized."); } void loop() { sdWrite("none"); } /* Filename MUST be <=8 characters (not including the file extension) or the file will not be created */ bool sdWrite(String data) { File dataFile = SD.open("alex.txt", FILE_WRITE); // if the file is available, write to it: if (dataFile) { dataFile.println(data); dataFile.close(); // print to the serial port too: Serial.println(data); } // if the file isn't open, pop up an error: else { Serial.println("error opening file"); dataFile.close(); } }
Add original code for writing to SD card.
Add original code for writing to SD card.
Arduino
mit
karikawa/2014-2015,karikawa/2014-2015,UCLARocketProject/2014-2015,UCLARocketProject/2014-2015,UCLARocketProject/2014-2015,karikawa/2014-2015,UCLARocketProject/2014-2015,karikawa/2014-2015,UCLARocketProject/2014-2015,karikawa/2014-2015
ee46a2cfa4c51515ba226b0a8bd1a1a2236b0f56
Arduino/HX711_LoadCell/HX711_LoadCell.ino
Arduino/HX711_LoadCell/HX711_LoadCell.ino
/* Inspired from code HX711 demo from Nathan Seidle, SparkFun Electronics This example code uses bogde's excellent library: https://github.com/bogde/HX711 bogde's library is released under a GNU GENERAL PUBLIC LICENSE The HX711 does one thing well: read load cells. T Arduino pin (Nano) 2 -> HX711 CLK 3 -> HX711 DAT 3V3 -> HX711 VCC GND -> HX711 GND 5V -> Radio VCC 4 -> Radio GND RX -> Radio TX TX -> Radio RX The HX711 board can be powered from 2.7V to 5V so the Arduino 5V power should be fine. */ #include "HX711.h" #define calibration_factor -7050.0 //This value is obtained using the SparkFun_HX711_Calibration sketch #define DOUT 3 #define CLK 2 #define GND 4 HX711 scale(DOUT, CLK); void setup() { pinMode(GND, OUTPUT); Serial.begin(57600); Serial.println("HX711 scale demo"); // Result of calibration scale.set_offset(8177300); scale.set_scale(-146.7); //Read the raw value Serial.println("Readings:"); } void loop() { digitalWrite(GND, LOW); Serial.print("Reading: "); Serial.print(scale.read_average(), 1); //raw value Serial.print(" "); Serial.print(scale.get_units(), 1); //scaled and offset after calibration Serial.print(" g"); Serial.println(); }
Add script to read HX711 and load cell
Add script to read HX711 and load cell
Arduino
mit
baptistelabat/robokite,baptistelabat/robokite,baptistelabat/robokite,baptistelabat/robokite,baptistelabat/robokite,baptistelabat/robokite,baptistelabat/robokite,baptistelabat/robokite
e4f65dfd39c105169d200e2d5dd0af76593e9411
shipStation/stepper_demo/stepper_demo.ino
shipStation/stepper_demo/stepper_demo.ino
#include <AccelStepper.h> #include <MultiStepper.h> #include <math.h> /* Written for ST6600 stepper driver * PUL+ 5v * PUL- Arduino pin 9/11 * DIR+ 5v * DIR- Arduino pin 8/10 * DC+ 24v power supply * DC- Gnd on power supply & Gnd on Arduino */ // Each step is 0.12 degrees, or 0.002094395 radians #define STEPANGLE 0.002094395 #define PI 3.1415926535897932384626433832795 AccelStepper xAxis(1,8,9); AccelStepper yAxis(1,10,11); MultiStepper steppers; long positions[2]; // x, y float angle = 0; // Radians, used to find x,y on a circle long centerX = 0; // May be useful later long centerY = 0; long radius = 100; void setup() { // Initialize pins pinMode(8, OUTPUT); // x direction pin pinMode(9, OUTPUT); // x step pin pinMode(10, OUTPUT); // y direction pin pinMode(11, OUTPUT); // y step pin Serial.begin(115200); // Adjust these values after seeing it in action. xAxis.setMaxSpeed(300); xAxis.setAcceleration(100); yAxis.setMaxSpeed(300); yAxis.setAcceleration(100); // Add individual steppers to the multistepper object steppers.addStepper(xAxis); steppers.addStepper(yAxis); } void updatePos(float degs) { // Moves to a point on a circle, based on radius and angle // Blocks until finished float rads = degs * PI / 180; positions[0] = radius*cos(rads)+centerX; // x positions[1] = radius*sin(rads)+centerY; // y Serial.print("Deg = "); Serial.print(degs); Serial.print(", "); Serial.print(positions[0]); Serial.print(", "); Serial.print(positions[1]); Serial.println("."); steppers.moveTo(positions); steppers.runSpeedToPosition(); } void loop() { // Spiral outwards for(int degs=0; degs<360; degs++){ updatePos(degs); radius += 10; } // Spiral inwards for(int degs=360; degs>0; degs--){ updatePos(degs); radius -= 10; } }
Add early version of ship station demonstration software for OSU Expo
Add early version of ship station demonstration software for OSU Expo
Arduino
mit
LBCC-SpaceClub/HAB2017,LBCC-SpaceClub/HAB2017,LBCC-SpaceClub/HAB2017
d194f63a3d3346041918773d1e71d5e111da63ba
examples/Boards_Ethernet/Arduino_MKR_ETH/Arduino_MKR_ETH.ino
examples/Boards_Ethernet/Arduino_MKR_ETH/Arduino_MKR_ETH.ino
/************************************************************* Download latest Blynk library here: https://github.com/blynkkk/blynk-library/releases/latest Blynk is a platform with iOS and Android apps to control Arduino, Raspberry Pi and the likes over the Internet. You can easily build graphic interfaces for all your projects by simply dragging and dropping widgets. Downloads, docs, tutorials: http://www.blynk.cc Sketch generator: http://examples.blynk.cc Blynk community: http://community.blynk.cc Social networks: http://www.fb.com/blynkapp http://twitter.com/blynk_app Blynk library is licensed under MIT license This example code is in public domain. ************************************************************* This example shows how to use Arduino MKR ETH shield to connect your project to Blynk. Note: This requires the latest Ethernet library (2.0.0+) from http://librarymanager/all#Ethernet WARNING: If you have an SD card, you may need to disable it by setting pin 4 to HIGH. Read more here: https://www.arduino.cc/en/Main/ArduinoEthernetShield Feel free to apply it to any other example. It's simple! *************************************************************/ /* Comment this out to disable prints and save space */ #define BLYNK_PRINT Serial #include <SPI.h> #include <Ethernet.h> #include <BlynkSimpleEthernet.h> // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "YourAuthToken"; #define MKRETH_CS 5 #define SDCARD_CS 4 void setup() { // Debug console Serial.begin(9600); pinMode(SDCARD_CS, OUTPUT); digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card Ethernet.init(MKRETH_CS); // Init MKR ETH shield Blynk.begin(auth); // You can also specify server: //Blynk.begin(auth, "blynk-cloud.com", 80); //Blynk.begin(auth, IPAddress(192,168,1,100), 8080); // For more options, see Boards_Ethernet/Arduino_Ethernet_Manual example } void loop() { Blynk.run(); }
Add support for Arduino MKR ETH shield
Add support for Arduino MKR ETH shield
Arduino
mit
blynkkk/blynk-library,blynkkk/blynk-library,blynkkk/blynk-library,blynkkk/blynk-library,blynkkk/blynk-library
34be16c8da728997f62a6d4ce679e3d5c8f9992a
libraries/esp8266/examples/ConfigFile/ConfigFile.ino
libraries/esp8266/examples/ConfigFile/ConfigFile.ino
// Example: storing JSON configuration file in flash file system // // Uses ArduinoJson library by Benoit Blanchon. // https://github.com/bblanchon/ArduinoJson // // Created Aug 10, 2015 by Ivan Grokhotkov. // // This example code is in the public domain. #include <ArduinoJson.h> #include "FS.h" bool loadConfig() { File configFile = SPIFFS.open("/config.json", "r"); if (!configFile) { Serial.println("Failed to open config file"); return false; } size_t size = configFile.size(); if (size > 1024) { Serial.println("Config file size is too large"); return false; } // Allocate a buffer to store contents of the file. std::unique_ptr<char[]> buf(new char[size]); // We don't use String here because ArduinoJson library requires the input // buffer to be mutable. If you don't use ArduinoJson, you may as well // use configFile.readString instead. configFile.readBytes(buf.get(), size); StaticJsonBuffer<200> jsonBuffer; JsonObject& json = jsonBuffer.parseObject(buf.get()); if (!json.success()) { Serial.println("Failed to parse config file"); return false; } const char* serverName = json["serverName"]; const char* accessToken = json["accessToken"]; // Real world application would store these values in some variables for // later use. Serial.print("Loaded serverName: "); Serial.println(serverName); Serial.print("Loaded accessToken: "); Serial.println(accessToken); return true; } bool saveConfig() { StaticJsonBuffer<200> jsonBuffer; JsonObject& json = jsonBuffer.createObject(); json["serverName"] = "api.example.com"; json["accessToken"] = "128du9as8du12eoue8da98h123ueh9h98"; File configFile = SPIFFS.open("/config.json", "w"); if (!configFile) { Serial.println("Failed to open config file for writing"); return false; } json.printTo(configFile); return true; } void setup() { Serial.begin(115200); Serial.println(""); delay(1000); Serial.println("Mounting FS..."); if (!SPIFFS.begin()) { Serial.println("Failed to mount file system"); return; } if (!saveConfig()) { Serial.println("Failed to save config"); } else { Serial.println("Config saved"); } if (!loadConfig()) { Serial.println("Failed to load config"); } else { Serial.println("Config loaded"); } } void loop() { }
Add example for storing JSON config file in SPIFFS
Add example for storing JSON config file in SPIFFS
Arduino
lgpl-2.1
Cloudino/Cloudino-Arduino-IDE,me-no-dev/Arduino,jes/Arduino,Cloudino/Arduino,chrisfraser/Arduino,toastedcode/esp8266-Arduino,toastedcode/esp8266-Arduino,Cloudino/Arduino,Juppit/Arduino,Cloudino/Arduino,gguuss/Arduino,chrisfraser/Arduino,CanTireInnovations/Arduino,toastedcode/esp8266-Arduino,sticilface/Arduino,hallard/Arduino,hallard/Arduino,Adam5Wu/Arduino,lrmoreno007/Arduino,hallard/Arduino,Cloudino/Arduino,edog1973/Arduino,wemos/Arduino,Juppit/Arduino,Cloudino/Cloudino-Arduino-IDE,NullMedia/Arduino,Juppit/Arduino,NextDevBoard/Arduino,CanTireInnovations/Arduino,toastedcode/esp8266-Arduino,jes/Arduino,lrmoreno007/Arduino,sticilface/Arduino,wemos/Arduino,quertenmont/Arduino,Juppit/Arduino,KaloNK/Arduino,Cloudino/Cloudino-Arduino-IDE,Adam5Wu/Arduino,gguuss/Arduino,Cloudino/Cloudino-Arduino-IDE,sticilface/Arduino,edog1973/Arduino,edog1973/Arduino,Links2004/Arduino,Cloudino/Cloudino-Arduino-IDE,quertenmont/Arduino,martinayotte/ESP8266-Arduino,quertenmont/Arduino,esp8266/Arduino,wemos/Arduino,KaloNK/Arduino,Juppit/Arduino,Lan-Hekary/Arduino,Adam5Wu/Arduino,Links2004/Arduino,me-no-dev/Arduino,esp8266/Arduino,gguuss/Arduino,Cloudino/Arduino,NextDevBoard/Arduino,Cloudino/Arduino,KaloNK/Arduino,KaloNK/Arduino,lrmoreno007/Arduino,me-no-dev/Arduino,me-no-dev/Arduino,CanTireInnovations/Arduino,edog1973/Arduino,CanTireInnovations/Arduino,esp8266/Arduino,lrmoreno007/Arduino,gguuss/Arduino,Cloudino/Arduino,Cloudino/Cloudino-Arduino-IDE,KaloNK/Arduino,Adam5Wu/Arduino,chrisfraser/Arduino,Links2004/Arduino,quertenmont/Arduino,NullMedia/Arduino,edog1973/Arduino,martinayotte/ESP8266-Arduino,esp8266/Arduino,CanTireInnovations/Arduino,esp8266/Arduino,NullMedia/Arduino,toastedcode/esp8266-Arduino,sticilface/Arduino,quertenmont/Arduino,me-no-dev/Arduino,Lan-Hekary/Arduino,CanTireInnovations/Arduino,NullMedia/Arduino,hallard/Arduino,jes/Arduino,hallard/Arduino,NextDevBoard/Arduino,martinayotte/ESP8266-Arduino,NextDevBoard/Arduino,wemos/Arduino,Cloudino/Cloudino-Arduino-IDE,Links2004/Arduino,gguuss/Arduino,Lan-Hekary/Arduino,chrisfraser/Arduino,CanTireInnovations/Arduino,martinayotte/ESP8266-Arduino,lrmoreno007/Arduino,jes/Arduino,chrisfraser/Arduino,Lan-Hekary/Arduino,martinayotte/ESP8266-Arduino,Links2004/Arduino,NextDevBoard/Arduino,jes/Arduino,NullMedia/Arduino,wemos/Arduino,Lan-Hekary/Arduino,Adam5Wu/Arduino,sticilface/Arduino
f69ffade852a97c095e1634706865caff13fa9ff
examples/Boards_USB_Serial/Blue_Pill_STM32F103C8/Blue_Pill_STM32F103C8.ino
examples/Boards_USB_Serial/Blue_Pill_STM32F103C8/Blue_Pill_STM32F103C8.ino
/************************************************************** * Blynk is a platform with iOS and Android apps to control * Arduino, Raspberry Pi and the likes over the Internet. * You can easily build graphic interfaces for all your * projects by simply dragging and dropping widgets. * * Downloads, docs, tutorials: http://www.blynk.cc * Blynk community: http://community.blynk.cc * Social networks: http://www.fb.com/blynkapp * http://twitter.com/blynk_app * * Blynk library is licensed under MIT license * This example code is in public domain. * ************************************************************** * This example shows how to use ordinary Arduino Serial * to connect your project to Blynk. * Feel free to apply it to any other example. It's simple! * * Requires STM32duino: https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki/Installation * ************************************************************** * USB HOWTO: http://tiny.cc/BlynkUSB **************************************************************/ #define BLYNK_PRINT Serial2 #include <BlynkSimpleStream.h> // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "YourAuthToken"; void setup() { // Debug console Serial2.begin(9600); // Blynk will work through Serial Serial.begin(9600); Blynk.begin(auth, Serial); } void loop() { Blynk.run(); }
Add STM32F103 Blue Pill example
Add STM32F103 Blue Pill example
Arduino
mit
blynkkk/blynk-library,ivankravets/blynk-library,ivankravets/blynk-library,blynkkk/blynk-library,ivankravets/blynk-library,blynkkk/blynk-library,blynkkk/blynk-library,ivankravets/blynk-library,ivankravets/blynk-library,blynkkk/blynk-library
8ada9c9add04c5095a100147372537472b77eb5f
hardware/esp8266com/esp8266/libraries/esp8266/examples/ConfigFile/ConfigFile.ino
hardware/esp8266com/esp8266/libraries/esp8266/examples/ConfigFile/ConfigFile.ino
// Example: storing JSON configuration file in flash file system // // Uses ArduinoJson library by Benoit Blanchon. // https://github.com/bblanchon/ArduinoJson // // Created Aug 10, 2015 by Ivan Grokhotkov. // // This example code is in the public domain. #include <ArduinoJson.h> #include "FS.h" bool loadConfig() { File configFile = SPIFFS.open("/config.json", "r"); if (!configFile) { Serial.println("Failed to open config file"); return false; } size_t size = configFile.size(); if (size > 1024) { Serial.println("Config file size is too large"); return false; } // Allocate a buffer to store contents of the file. std::unique_ptr<char[]> buf(new char[size]); // We don't use String here because ArduinoJson library requires the input // buffer to be mutable. If you don't use ArduinoJson, you may as well // use configFile.readString instead. configFile.readBytes(buf.get(), size); StaticJsonBuffer<200> jsonBuffer; JsonObject& json = jsonBuffer.parseObject(buf.get()); if (!json.success()) { Serial.println("Failed to parse config file"); return false; } const char* serverName = json["serverName"]; const char* accessToken = json["accessToken"]; // Real world application would store these values in some variables for // later use. Serial.print("Loaded serverName: "); Serial.println(serverName); Serial.print("Loaded accessToken: "); Serial.println(accessToken); return true; } bool saveConfig() { StaticJsonBuffer<200> jsonBuffer; JsonObject& json = jsonBuffer.createObject(); json["serverName"] = "api.example.com"; json["accessToken"] = "128du9as8du12eoue8da98h123ueh9h98"; File configFile = SPIFFS.open("/config.json", "w"); if (!configFile) { Serial.println("Failed to open config file for writing"); return false; } json.printTo(configFile); return true; } void setup() { Serial.begin(115200); Serial.println(""); delay(1000); Serial.println("Mounting FS..."); if (!SPIFFS.begin()) { Serial.println("Failed to mount file system"); return; } if (!saveConfig()) { Serial.println("Failed to save config"); } else { Serial.println("Config saved"); } if (!loadConfig()) { Serial.println("Failed to load config"); } else { Serial.println("Config loaded"); } } void loop() { }
Add example for storing JSON config file in SPIFFS
Add example for storing JSON config file in SPIFFS
Arduino
lgpl-2.1
koltegirish/Arduino,wdoganowski/Arduino,radut/Arduino,mateuszdw/Arduino,ogahara/Arduino,radut/Arduino,koltegirish/Arduino,gonium/Arduino,leftbrainstrain/Arduino-ESP8266,eeijcea/Arduino-1,ssvs111/Arduino,paulo-raca/ESP8266-Arduino,drpjk/Arduino,tannewt/Arduino,aichi/Arduino-2,ssvs111/Arduino,mangelajo/Arduino,mateuszdw/Arduino,ssvs111/Arduino,mateuszdw/Arduino,wdoganowski/Arduino,tannewt/Arduino,noahchense/Arduino-1,eeijcea/Arduino-1,drpjk/Arduino,paulmand3l/Arduino,ogahara/Arduino,gonium/Arduino,smily77/Arduino,sanyaade-iot/Arduino-1,paulo-raca/ESP8266-Arduino,weera00/Arduino,weera00/Arduino,wdoganowski/Arduino,EmuxEvans/Arduino,mangelajo/Arduino,gonium/Arduino,spapadim/Arduino,zenmanenergy/Arduino,spapadim/Arduino,gonium/Arduino,gonium/Arduino,EmuxEvans/Arduino,noahchense/Arduino-1,noahchense/Arduino-1,weera00/Arduino,mangelajo/Arduino,koltegirish/Arduino,zenmanenergy/Arduino,leftbrainstrain/Arduino-ESP8266,sanyaade-iot/Arduino-1,noahchense/Arduino-1,noahchense/Arduino-1,EmuxEvans/Arduino,sanyaade-iot/Arduino-1,zenmanenergy/Arduino,radut/Arduino,zenmanenergy/Arduino,paulmand3l/Arduino,noahchense/Arduino-1,weera00/Arduino,koltegirish/Arduino,drpjk/Arduino,radut/Arduino,smily77/Arduino,myrtleTree33/Arduino,myrtleTree33/Arduino,paulo-raca/ESP8266-Arduino,jomolinare/Arduino,aichi/Arduino-2,aichi/Arduino-2,mangelajo/Arduino,sanyaade-iot/Arduino-1,wdoganowski/Arduino,jomolinare/Arduino,wdoganowski/Arduino,wdoganowski/Arduino,leftbrainstrain/Arduino-ESP8266,EmuxEvans/Arduino,EmuxEvans/Arduino,weera00/Arduino,smily77/Arduino,mangelajo/Arduino,mateuszdw/Arduino,tannewt/Arduino,drpjk/Arduino,mangelajo/Arduino,mateuszdw/Arduino,leftbrainstrain/Arduino-ESP8266,paulo-raca/ESP8266-Arduino,spapadim/Arduino,eeijcea/Arduino-1,paulmand3l/Arduino,ogahara/Arduino,koltegirish/Arduino,smily77/Arduino,mateuszdw/Arduino,radut/Arduino,aichi/Arduino-2,radut/Arduino,myrtleTree33/Arduino,paulo-raca/ESP8266-Arduino,sanyaade-iot/Arduino-1,weera00/Arduino,ssvs111/Arduino,smily77/Arduino,spapadim/Arduino,drpjk/Arduino,smily77/Arduino,smily77/Arduino,mateuszdw/Arduino,myrtleTree33/Arduino,leftbrainstrain/Arduino-ESP8266,ogahara/Arduino,koltegirish/Arduino,myrtleTree33/Arduino,EmuxEvans/Arduino,jomolinare/Arduino,aichi/Arduino-2,jomolinare/Arduino,tannewt/Arduino,sanyaade-iot/Arduino-1,jomolinare/Arduino,spapadim/Arduino,ogahara/Arduino,drpjk/Arduino,mangelajo/Arduino,EmuxEvans/Arduino,leftbrainstrain/Arduino-ESP8266,ssvs111/Arduino,tannewt/Arduino,weera00/Arduino,paulmand3l/Arduino,zenmanenergy/Arduino,ogahara/Arduino,tannewt/Arduino,gonium/Arduino,radut/Arduino,koltegirish/Arduino,zenmanenergy/Arduino,eeijcea/Arduino-1,paulmand3l/Arduino,paulmand3l/Arduino,paulo-raca/ESP8266-Arduino,tannewt/Arduino,drpjk/Arduino,aichi/Arduino-2,spapadim/Arduino,gonium/Arduino,ssvs111/Arduino,jomolinare/Arduino,eeijcea/Arduino-1,ssvs111/Arduino,eeijcea/Arduino-1,myrtleTree33/Arduino,aichi/Arduino-2,spapadim/Arduino,leftbrainstrain/Arduino-ESP8266,eeijcea/Arduino-1,myrtleTree33/Arduino,sanyaade-iot/Arduino-1,jomolinare/Arduino,zenmanenergy/Arduino,wdoganowski/Arduino,noahchense/Arduino-1,ogahara/Arduino,paulo-raca/ESP8266-Arduino,paulmand3l/Arduino
e1bff356943611f3df9dc6a11a4c3a97a1918cae
GoliathMqttSensor.ino
GoliathMqttSensor.ino
/* Stub to allow build from Arduino IDE */ /* Includes to external libraries */ #include <MemoryFree.h> #include <Countdown.h> #include <MQTTClient.h> #include <SoftwareSerial.h>
Add 'ino' file to allow build from Arduino IDE
Add 'ino' file to allow build from Arduino IDE
Arduino
mit
monstrenyatko/ArduinoMqttNode
a6933a552ad7992dc61b371211abcb165846e503
ardupet.ino
ardupet.ino
char incomingByte = 0; const char lampCount = 4; const unsigned short doorUnlockTime = 2000; // in miliseconds bool lampStatus[lampCount]; bool doorStatus; unsigned short doorUnlockTimer; void setup() { Serial.begin(9600); pinMode(13, OUTPUT); for (int i = 0; i < lampCount; ++i) lampStatus[i] = false; doorStatus = false; } void loop() { if (Serial.available() > 2) { // Option can be 'r' (read) or 'w' (write) incomingByte = Serial.read(); if (incomingByte == 'r') { // Option can be 'l' (lamp) or 'd' (door) incomingByte = Serial.read(); if (incomingByte == 'l') { // Option can be 0 to (lampCount-1) (lamp id) incomingByte = Serial.read(); if (incomingByte < lampCount) Serial.write(lampStatus[incomingByte]); } else if (incomingByte == 'd') { // Discard last byte, since door does not have id and last byte has to be consumed Serial.read(); Serial.write(doorStatus); } } else if (incomingByte == 'w') { // Option can be 'l' (lamp) or 'd' (door) incomingByte = Serial.read(); if (incomingByte == 'l') { // Option can be 0 to (lampCount-1) (lamp id) incomingByte = Serial.read(); if (incomingByte < lampCount) { // TODO: Logic to invert lamp status lampStatus[incomingByte] = !lampStatus[incomingByte]; } } else if (incomingByte == 'd') { // Discard last byte, since door does not have id and last byte has to be consumed Serial.read(); // TODO: Logic to unlock the door doorStatus = true; doorUnlockTimer = doorUnlockTime; } } } if (doorUnlockTimer > 0) { digitalWrite(13, HIGH); --doorUnlockTimer; } else { // TODO: Logic to lock the door? digitalWrite(13, LOW); doorStatus = false; } // Delay to make board timing predictable delay(1); }
Include code sample for Arduino
Include code sample for Arduino
Arduino
mit
ranisalt/ardupet
68562c1f7ea7f13af351ba8b1cdd08a28228bea8
steppercontrol/steppercontrol.ino
steppercontrol/steppercontrol.ino
int motorPin = 9; int switchPin = 7; int motorStep = 0; int maxStep = 200; int minimumStepDelay = 2; String motorState = String("off"); void makeStep() { digitalWrite(motorPin, HIGH); digitalWrite(motorPin, LOW); motorStep += 1; if (motorStep > maxStep) { motorStep = 0; } } void resetMotor() { for (int i = motorStep; i < maxStep; i++) { makeStep(); delay(minimumStepDelay); } } void setup() { pinMode(switchPin, INPUT); pinMode(motorPin, OUTPUT); digitalWrite(switchPin, HIGH); Serial.begin(9600); } void loop() { if(Serial.available() > 0) { char command = Serial.read(); switch (command) { case 'd': Serial.println(String("Current step: ") + motorStep); break; case 's': makeStep(); Serial.println(motorStep); break; case 'r': resetMotor(); Serial.println(String("Motor reset. (Step is ") + motorStep + String(")")); } } }
Add motor control arduino sketch
Add motor control arduino sketch
Arduino
mit
kirberich/3dscanner
199d247263c93c7019477ebbd4ae445be84f91e5
examples/Serial/Serial.ino
examples/Serial/Serial.ino
#include "VdlkinoSerial.h" VdlkinoSerial vdlkino(14, 6, &Serial); void setup() { Serial.begin(9600); } void loop() { vdlkino.run(); }
Add example of using serial
Add example of using serial
Arduino
mit
eduardoklosowski/vdlkino,eduardoklosowski/vdlkino
bb19d8ebeaca67e85b036df5914bcf588bcd9235
examples/determining_gain/determining_gain.ino
examples/determining_gain/determining_gain.ino
// Gain Setting Example // Demonstrates the filter response with unity input to // get the appropriate value for the filter gain setting. #include <FIR.h> // Make an instance of the FIR filter. In this example we'll use // floating point values and a 13 element filter. FIR<long, 13> fir; void setup() { Serial.begin(115200); // Start a serial port // Use an online tool to get these such as http://t-filter.engineerjs.com // This filter rolls off after 2 Hz for a 10 Hz sampling rate. long coef[13] = { 660, 470, -1980, -3830, 504, 10027, 15214, 10027, 504, -3830, -1980, 470, 660}; // Set the coefficients fir.setFilterCoeffs(coef); // Set the gain to 1 to find the actual gain. // After running this sketch you'll see the gain // value sould be 26916. long gain = 1; // Set the gain fir.setGain(gain); } void loop() { // Need to run at least the length of the filter. for (float i=0; i < 14; i++) { Serial.print("Iteration "); Serial.print(i+1); Serial.print(" -> "); Serial.println(fir.processReading(1)); // Input all unity values } while (true) {}; // Spin forever }
Add an example of how to determine the gain setting for a filter.
Add an example of how to determine the gain setting for a filter.
Arduino
mit
LeemanGeophysicalLLC/FIR_Filter_Arduino_Library
8d00a318388a53ea942ead48928d01b2de4dd520
examples/Boards_WiFi/Adafruit_Feather_M0_WiFi/Adafruit_Feather_M0_WiFi.ino
examples/Boards_WiFi/Adafruit_Feather_M0_WiFi/Adafruit_Feather_M0_WiFi.ino
/************************************************************** * Blynk is a platform with iOS and Android apps to control * Arduino, Raspberry Pi and the likes over the Internet. * You can easily build graphic interfaces for all your * projects by simply dragging and dropping widgets. * * Downloads, docs, tutorials: http://www.blynk.cc * Blynk community: http://community.blynk.cc * Social networks: http://www.fb.com/blynkapp * http://twitter.com/blynk_app * * Blynk library is licensed under MIT license * This example code is in public domain. * ************************************************************** * This example shows how to use Adafruit Feather M0 WiFi * to connect your project to Blynk. * * Note: This requires WiFi101 library * from http://librarymanager/all#WiFi101 * * Feel free to apply it to any other example. It's simple! * **************************************************************/ #define BLYNK_PRINT Serial // Comment this out to disable prints and save space #include <WiFi101.h> #include <BlynkSimpleWiFiShield101.h> // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "YourAuthToken"; // Your WiFi credentials. // Set password to "" for open networks. char ssid[] = "YourNetworkName"; char pass[] = "YourPassword"; void setup() { Serial.begin(9600); WiFi.setPins(8,7,4,2); Blynk.begin(auth, ssid, pass); // Or specify server using one of those commands: //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442); //Blynk.begin(auth, ssid, pass, server_ip, port); } void loop() { Blynk.run(); }
Add Feather M0 WiFi example
Add Feather M0 WiFi example
Arduino
mit
blynkkk/blynk-library,blynkkk/blynk-library,ivankravets/blynk-library,blynkkk/blynk-library,ivankravets/blynk-library,blynkkk/blynk-library,ivankravets/blynk-library,ivankravets/blynk-library,ivankravets/blynk-library,blynkkk/blynk-library
8c1b7fe88de6e5c300388a29c035501c8eab2fb4
neopixel_rgb_knob/neopixel_rgb_knob.ino
neopixel_rgb_knob/neopixel_rgb_knob.ino
/* * neopixel_rgb_knob * * This is a test program to adjust the rgb of a strip of * neopixels useing three potentiometers. */ #include <Adafruit_NeoPixel.h> #ifdef __AVR__ #include <avr/power.h> // Required for 16 MHz Adafruit Trinket #endif // Which pin on the Arduino is connected to the NeoPixels? // On a Trinket or Gemma we suggest changing this to 1: #define LED_PIN 6 // How many NeoPixels are attached to the Arduino? #define LED_COUNT 8 // Declare our NeoPixel strip object: Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); /* Set up three potentiometers to adjust the rgb colors */ #define knob_r 0 #define knob_g 1 #define knob_b 2 void setup() { // put your setup code here, to run once: // These lines are specifically to support the Adafruit Trinket 5V 16 MHz. // Any other board, you can remove this part (but no harm leaving it): #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) clock_prescale_set(clock_div_1); #endif // END of Trinket-specific code. strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) strip.show(); // Turn OFF all pixels ASAP strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255) } void loop() { // put your main code here, to run repeatedly: int r, g, b; /* Get each of the rgb values and then map from 0-1023 to 0-255. */ r = analogRead(knob_r); r = map(r, 0, 1023, 0, 255); g = analogRead(knob_g); g = map(g, 0, 1023, 0, 255); b = analogRead(knob_b); b = map(b, 0, 1023, 0, 255); /* set all of the pixels to the same color */ setAll(r, g, b); } /* Simple function to set all of the neopixels to the same color */ void setAll(byte red, byte green, byte blue) { for(int i = 0; i < LED_COUNT; i++ ) { strip.setPixelColor(i, red, green, blue); } strip.show(); }
Add program to adjust pixel color with three potentiometers.
Add program to adjust pixel color with three potentiometers.
Arduino
mit
rlynch3456/Arduino
8b81bd258e7d5d457a57ccd7b007a83bfd5f7cf4
arduino/tempsens/tempsens.ino
arduino/tempsens/tempsens.ino
#include <OneWire.h> #include <DallasTemperature.h> // Change these if appropriate // The pin that sensors are connected to #define ONE_WIRE_BUS 2 // What precision to set the sensor to #define TEMPERATURE_PRECISION 11 OneWire one_wire(ONE_WIRE_BUS); DallasTemperature sensors(&one_wire); // We will store an array of probes we find on initial startup. If you have // more than 20 probes, feel free to bump this number and see if it'll actually // work at all. DeviceAddress probes[20]; int num_probes = 0; void setup() { Serial.begin(9600); sensors.begin(); // Set all devices to the same resolution sensors.setResolution(TEMPERATURE_PRECISION); // Find our sensors, use num_probes as a handy counter. one_wire.reset_search(); while (one_wire.search(probes[num_probes])) { num_probes++; } } void print_address(DeviceAddress device_address) { // Device address is 8 bytes, iterate over them. for (byte i = 0; i < 8; i++) { if (device_address[i] < 16) { Serial.print("0"); } Serial.print(device_address[i], HEX); } } void print_reading(DeviceAddress device_address) { // Print out data in the form of ADDRESS:TEMPERATURE // This bit's annoying enough to get its own function print_address(device_address); Serial.print(":"); Serial.print(sensors.getTempC(device_address)); Serial.print('\n'); } void loop() { // Make sure we're not just spitting out some constant meaningless numbers sensors.requestTemperatures(); for (int i = 0; i < num_probes; i++) { print_reading(probes[i]); } }
Add Arduino code for reporting temperature sensor data.
Add Arduino code for reporting temperature sensor data.
Arduino
mit
turmoni/temp-probe-exporter,turmoni/temp-probe-exporter
b34f772518509faa3ad4c518815ec765fcd50289
examples/Boards_BLE/Serial_HC05_HC06/Serial_HC05_HC06.ino
examples/Boards_BLE/Serial_HC05_HC06/Serial_HC05_HC06.ino
/************************************************************** * Blynk is a platform with iOS and Android apps to control * Arduino, Raspberry Pi and the likes over the Internet. * You can easily build graphic interfaces for all your * projects by simply dragging and dropping widgets. * * Downloads, docs, tutorials: http://www.blynk.cc * Blynk community: http://community.blynk.cc * Social networks: http://www.fb.com/blynkapp * http://twitter.com/blynk_app * * Blynk library is licensed under MIT license * This example code is in public domain. * ************************************************************** * This example shows how to use Arduino with HC-06/HC-05 * Bluetooth 2.0 Serial Port Profile (SPP) module * to connect your project to Blynk. * * Feel free to apply it to any other example. It's simple! * * NOTE: Bluetooth support is in beta! * **************************************************************/ // You could use a spare Hardware Serial on boards that have it (like Mega) #include <SoftwareSerial.h> SoftwareSerial DebugSerial(2, 3); // RX, TX #define BLYNK_PRINT DebugSerial #include <BlynkSimpleStream.h> // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "YourAuthToken"; void setup() { // Debug console DebugSerial.begin(9600); // Blynk will work through Serial Serial.begin(9600); Blynk.begin(auth, Serial); } void loop() { Blynk.run(); }
Add Bluetooth 2.0 Serial Port Profile (SPP) example
Add Bluetooth 2.0 Serial Port Profile (SPP) example
Arduino
mit
blynkkk/blynk-library,blynkkk/blynk-library,ivankravets/blynk-library,blynkkk/blynk-library,ivankravets/blynk-library,blynkkk/blynk-library,blynkkk/blynk-library,ivankravets/blynk-library,ivankravets/blynk-library,ivankravets/blynk-library
91e92761455d509bad933099e46635a2c435bcf1
Ard-Analog/AnalogIn/AnalogIn.ino
Ard-Analog/AnalogIn/AnalogIn.ino
const int analogInPin = A0; const int analogOutPin = 3; int sensorValue = 0; int outputValue = 0; void setup() { Serial.begin(9600); } void loop() { sensorValue = analogRead(analogInPin); outputValue = map(sensorValue, 0, 1023, 0, 255); analogWrite(analogOutPin, outputValue); // print the results to the serial monitor: Serial.print("sensor = " ); Serial.print(sensorValue); Serial.print("\t output = "); Serial.println(outputValue); delay(250); }
Add Arduino program for working with Analog data
Add Arduino program for working with Analog data
Arduino
cc0-1.0
CurtisIreland/electronics,CurtisIreland/electronics,CurtisIreland/electronics,CurtisIreland/electronics,CurtisIreland/electronics,CurtisIreland/electronics
d310e299c635043beefdd097bb92a978cbffde80
examples/receive_interruptFD/receive_interruptFD.ino
examples/receive_interruptFD/receive_interruptFD.ino
// demo: CAN-BUS Shield, receive data with interrupt mode // when in interrupt mode, the data coming can't be too fast, must >20ms, or else you can use check mode // loovee, 2014-6-13 #include <SPI.h> #include "mcp2518fd_can.h" /*SAMD core*/ #ifdef ARDUINO_SAMD_VARIANT_COMPLIANCE #define SERIAL SerialUSB #else #define SERIAL Serial #endif #define CAN_2518FD // the cs pin of the version after v1.1 is default to D9 // v0.9b and v1.0 is default D10 const int SPI_CS_PIN = BCM8; const int CAN_INT_PIN = BCM25; #ifdef CAN_2518FD mcp2518fd CAN(SPI_CS_PIN); // Set CS pin #endif unsigned char flagRecv = 0; unsigned char len = 0; unsigned char buf[64]; char str[20]; void setup() { SERIAL.begin(115200); while (!SERIAL) { ; // wait for serial port to connect. Needed for native USB port only } CAN.setMode(0); while (0 != CAN.begin((byte)CAN_500K_1M)) { // init can bus : baudrate = 500k SERIAL.println("CAN BUS Shield init fail"); SERIAL.println(" Init CAN BUS Shield again"); delay(100); } byte mode = CAN.getMode(); SERIAL.printf("CAN BUS get mode = %d\n\r",mode); SERIAL.println("CAN BUS Shield init ok!"); SERIAL.println("CAN BUS Shield init ok!"); pinMode(CAN_INT_PIN, INPUT); attachInterrupt(digitalPinToInterrupt(CAN_INT_PIN), MCP2515_ISR, FALLING); // start interrupt } void MCP2515_ISR() { flagRecv = 1; } void loop() { if (flagRecv) { // check if get data flagRecv = 0; // clear flag SERIAL.println("into loop"); // iterate over all pending messages // If either the bus is saturated or the MCU is busy, // both RX buffers may be in use and reading a single // message does not clear the IRQ conditon. while (CAN_MSGAVAIL == CAN.checkReceive()) { // read data, len: data length, buf: data buf SERIAL.println("checkReceive"); CAN.readMsgBuf(&len, buf); // print the data for (int i = 0; i < len; i++) { SERIAL.print(buf[i]); SERIAL.print("\t"); } SERIAL.println(); } } } /********************************************************************************************************* END FILE *********************************************************************************************************/
Add canbus FD receive interrupt example
Add canbus FD receive interrupt example
Arduino
mit
Seeed-Studio/CAN_BUS_Shield,Seeed-Studio/CAN_BUS_Shield
dae399e6ab31d9a5d4b62a05a5bf047e16fe8c2b
Project_7/Project_7.ino
Project_7/Project_7.ino
int notes[] = {262, 294, 330, 349}; void setup() { Serial.begin(9600); } void loop() { int keyVal = analogRead(A0); Serial.println(keyVal); if (keyVal == 1023) { tone(8, notes[0]); } else if (keyVal >= 950 && keyVal <= 1010) { tone(8, notes[1]); } else if (keyVal >= 505 && keyVal <= 515) { tone(8, notes[2]); } else if (keyVal >= 5 && keyVal <= 10) { tone(8, notes[3]); } else { noTone(8); } }
Switch keyboard with resistor ladder
Switch keyboard with resistor ladder
Arduino
mit
martindisch/Arduino
b9065c665e649c45b8ed3113c044845ccf27dfe7
examples/Boards_WiFi/Sparkfun_Blynk_Board/Sparkfun_Blynk_Board.ino
examples/Boards_WiFi/Sparkfun_Blynk_Board/Sparkfun_Blynk_Board.ino
/************************************************************** * Blynk is a platform with iOS and Android apps to control * Arduino, Raspberry Pi and the likes over the Internet. * You can easily build graphic interfaces for all your * projects by simply dragging and dropping widgets. * * Downloads, docs, tutorials: http://www.blynk.cc * Blynk community: http://community.blynk.cc * Social networks: http://www.fb.com/blynkapp * http://twitter.com/blynk_app * * Blynk library is licensed under MIT license * This example code is in public domain. * ************************************************************** * This example runs on Sparkfun Blynk Board. * * You need to install this for ESP8266 development: * https://github.com/esp8266/Arduino * * NOTE: You can select NodeMCU 1.0 (compatible board) * in the Tools -> Board menu * * Change WiFi ssid, pass, and Blynk auth token to run :) * **************************************************************/ #define BLYNK_PRINT Serial // Comment this out to disable prints and save space #include <ESP8266WiFi.h> #include <BlynkSimpleEsp8266.h> // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "YourAuthToken"; // Your WiFi credentials. // Set password to "" for open networks. char ssid[] = "YourNetworkName"; char pass[] = "YourPassword"; void setup() { Serial.begin(9600); Blynk.begin(auth, ssid, pass); } void loop() { Blynk.run(); }
Add separate Blynk Board example. It deserves one! ;)
Add separate Blynk Board example. It deserves one! ;)
Arduino
mit
blynkkk/blynk-library,ivankravets/blynk-library,ivankravets/blynk-library,blynkkk/blynk-library,blynkkk/blynk-library,blynkkk/blynk-library,ivankravets/blynk-library,ivankravets/blynk-library,ivankravets/blynk-library,blynkkk/blynk-library
86d706332f5fd89de122b9904497fb2cdd581df0
Sensor/NodeMcu/sensor/sensor.ino
Sensor/NodeMcu/sensor/sensor.ino
#include <ESP8266WiFi.h> const char* ssid = "FRITZ!Box Fon WLAN 7360"; const char* password = "62884846722859294257"; const char* host = "192.168.178.34"; char* clientId = "photo1"; char* requestBody = "{ \"name\":\"%s\", \"weatherData\": { \"temperature\":\"%f\", \"humidity\":\"%f\" } }"; int delayInMillis = 10000; void setup() { Serial.begin(115200); delay(10); // We start by connecting to a WiFi network Serial.println(); Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); } int value = 0; void loop() { delay(5000); ++value; Serial.print("connecting to "); Serial.println(host); // Use WiFiClient class to create TCP connections WiFiClient client; const int httpPort = 8080; if (!client.connect(host, httpPort)) { Serial.println("connection failed"); return; } String url = "/devices"; Serial.print("Requesting URL: "); Serial.println(url); //char* body = printf(requestBody, clientId, "90", "44"); // This will send the request to the server client.print("POST " + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n" + "Content-Type: application/json\r\n" + "Content-Length: 73\r\n" + "\r\n" + "{\"name\":\"node2\", \"weatherData\": { \"temperature\":\"33\", \"humidity\":\"55\" } }"); unsigned long timeout = millis(); while (client.available() == 0) { if (millis() - timeout > 8000) { Serial.println(">>> Client Timeout !"); client.stop(); return; } } // Read all the lines of the reply from server and print them to Serial while(client.available()){ String line = client.readStringUntil('\r'); Serial.print(line); } Serial.println(); Serial.println("closing connection"); }
Add stub implementation for NodeMCU implementation
Add stub implementation for NodeMCU implementation
Arduino
apache-2.0
brave-warrior/Sensors-IoT,brave-warrior/Sensors-IoT,brave-warrior/Sensors-IoT