arduino code

arduino code

error: pathspec 'jtk/pi.ino' did not match any file(s) known to git

--- jtk/pi.ino
+++ jtk/pi.ino
@@ -0,0 +1,101 @@
+#define EN1 5  //DECLARANDO O ENABLE 1
+#define EN2 6  //DECLARANDO O ENABLE 2
+#define IN1 4  //DECLARANDO O MOTOR DIREITO DA FRENTE
+#define IN2 7  //DECLARANDO O MOTOR DIREITO DE TRAS
+#define IN3 8  //DECLARANDO O MOTOR ESQUERDO DA FRENTE
+#define IN4 12 //DECLARANDO O MOTOR ESQUERDO DE TRAS
+#define SE1 A5 //DECLARANDO O SENSOR ESQUERDO DO MEIO
+#define SD1 A4 //DECLARANDO O SENSOR DIREITO DO MEIO
+#define SE2 A3 //DECLARANDO O SENSOR ESQUERDO DA BORDA
+#define SD2 A2 //DECLARANDO O SENSOR DIREITO DA BORDA
+
+int V = 0;
+int x = 0;
+int i = 0;
+int comando = 0;
+
+void setup() {
+  //DECLARANDO SE SÃO ENTRADAS OU SAIDA
+  pinMode (EN1, OUTPUT);
+  pinMode (EN2, OUTPUT);
+  pinMode (IN1, OUTPUT);
+  pinMode (IN2, OUTPUT);
+  pinMode (IN3, OUTPUT);
+  pinMode (IN4, OUTPUT);
+  Serial.begin (9600);
+  Serial.println ("Bem vindo ao programa de teste do robô do PI da primeira fase!");
+  Serial.println ("Digite uma velocidade para o robô: ");
+  Serial.println ("1 para 0% ");
+  Serial.println ("2 para 25% ");
+  Serial.println ("3 para 50% ");
+  Serial.println ("4 para 100% ");
+
+  while (comando == 0){
+    comando = Serial.read();
+       if (comando == '1')
+          V = 0;
+      else if (comando == '2')
+          V = 64;
+      else if (comando == '3')
+          V = 127;
+      else if (comando == '4')
+          V = 255;
+     else
+          comando = 0;
+ }
+
+   Serial.println (comando);
+
+    analogWrite (EN1, V);
+    analogWrite (EN2, V);
+
+//  analogWrite (EN1, 255);
+//  analogWrite (EN2, 255);
+
+}
+void loop() {
+
+
+
+      Serial.println ("Andando para frente: ");
+      digitalWrite (IN1, HIGH); digitalWrite (IN2, LOW);
+      digitalWrite (IN3, HIGH); digitalWrite (IN4,LOW);
+      delay (4000);
+      digitalWrite (IN1, LOW); digitalWrite (IN2, LOW);
+      digitalWrite (IN3, LOW); digitalWrite (IN4,LOW);
+      delay (1000);
+      Serial.println ("Andando para Tras: ");
+      digitalWrite (IN1, LOW); digitalWrite (IN2, HIGH);
+      digitalWrite (IN3, LOW); digitalWrite (IN4,HIGH);
+      delay (4000);
+      digitalWrite (IN1, LOW); digitalWrite (IN2, LOW);
+      digitalWrite (IN3, LOW); digitalWrite (IN4,LOW);
+      delay (1000);
+      Serial.println ("Andando para esquerda: ");
+      digitalWrite (IN1, LOW); digitalWrite (IN2, HIGH);
+      digitalWrite (IN3, HIGH); digitalWrite (IN4,LOW);
+      delay (4000);
+      digitalWrite (IN1, LOW); digitalWrite (IN2, LOW);
+      digitalWrite (IN3, LOW); digitalWrite (IN4,LOW);
+      delay (1000);
+      Serial.println ("Andando para direita: ");
+      digitalWrite (IN1, HIGH); digitalWrite (IN2, LOW);
+      digitalWrite (IN3, LOW); digitalWrite (IN4,HIGH);
+      delay (4000);
+      digitalWrite (IN1, LOW); digitalWrite (IN2, LOW);
+      digitalWrite (IN3, LOW); digitalWrite (IN4,LOW);
+      delay (1000);
+      //Fazer 5 leituras dos sensores, Aproveitar para colocar na linha branca e preta uma a cada leitura
+      for (i = 0; i <= 5; i += 1){
+       Serial.print ("Sensor esquerdo 1: ");
+      Serial.println (analogRead(SE1));
+      Serial.print ("Sensor direito 1: ");
+      Serial.println (analogRead(SD1));
+      Serial.print ("Sensor esquerdo 2: ");
+      Serial.println (analogRead(SE2));
+      Serial.print ("Sensor direito 2: ");
+      Serial.println (analogRead(SD2));
+      Serial.println (" ");
+      delay (3000);
+    }
+}


Slower motorspeed forward.

Slower motorspeed forward.

error: pathspec 'Arduino/Motor' did not match any file(s) known to git
error: pathspec 'Controller/MotorController_NewHardware/MotorController_V04/MotorController_V04.ino' did not match any file(s) known to git


Added new Keyboard and mouse combined control

/bin/sh: 1: Syntax error: "(" unexpected


Simple Stat Start!

Simple Stat Start!

error: pathspec 'Firmware/Experimental' did not match any file(s) known to git
error: pathspec 'Versions/simplestat/simplestat.ino' did not match any file(s) known to git


slight cosmetics

slight cosmetics

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/trinamic/T-Bone.git/'


step1 we reach the target with each step


Arduino Files

Arduino Files

error: pathspec 'LivePlotter/LivePlotter.ino' did not match any file(s) known to git

--- LivePlotter/LivePlotter.ino
+++ LivePlotter/LivePlotter.ino
@@ -0,0 +1,121 @@
+/*
+
+Data logger with serial output for fast/live plotting on python
+
+Analog input on pin A0 is read-in at a sampling rate of ~xyz kS/s
+The sampling rate can be adjusted for more channels, or slower sampling rate,
+[channels must be enabled/disabled by setting the registers in the setup() method below],
+by adjusting the sampling_time variable
+
+The ADC data is buffered then sent quickly via SerialUSB. Since there is some overhead
+involved with Serial transfer, the data should be transferred in large quantities ( > 1 kB) so
+as to minimise total transmission time. Buffering will be memory-limited at some point. The
+largest buffer possible is currently untested!
+
+PySerial is used to grab the data from the serial port and read it into python. For this,
+the python module SixChannelReader.py has been written (in the same directory as this file),
+which provides class-based methods of reading in the data, as well as a method of
+synchronisation for triggering purposes.
+
+************
+** NOTE: the USB connection to the Arduino must be to the NATIVE port, not the programming port!
+************
+
+
+
+Author: James Keaveney
+19/05/2015
+
+*/
+
+// set up variables
+const int buffer_length = 2000; // length of data chunks sent at a time via SerialUSB
+
+//const long acquisition_time = 90000; // in ms (~2 minutes in real experiment)
+//const long settling_time_ms = 15000; // in ms
+
+const int sampling_time_sleep = 0; // in micros
+
+//const int TempAdjustPin = 2;
+
+String strTime = "";
+String strOut = "";
+String strC1 = "";
+
+unsigned long current_time;
+
+void setup() {
+
+  // set ADC resolution
+  analogReadResolution(12);
+
+  // manually set registers for faster analog reading than the normal arduino methods
+  ADC->ADC_MR |= 0xC0; // set free running mode (page 1333 of the Sam3X datasheet)
+  ADC->ADC_CHER = 0x80;  // enable channels  (see page 1338 of datasheet) on adc 7 (pin A0)
+                       // see also http://www.arduino.cc/en/Hacking/PinMappingSAM3X for the pin mapping between Arduino names and SAM3X pin names
+  ADC->ADC_CHDR = 0xFF7F; // disable all other channels
+  ADC->ADC_CR=2;       // begin ADC conversion
+
+
+  // initialise serial port
+  SerialUSB.begin(115200); // baud rate is ignored for USB - always at 12 Mb/s
+  while (!SerialUSB); // wait for USB serial port to be connected - wait for pc program to open the serial port
+
+}
+
+
+
+void loop() {
+
+  // data acquisition will start with a synchronisation step:
+  // python should send a single byte of data, the arduino will send one back to sync timeouts
+  int incoming = 0;
+  if (SerialUSB.available() > 0) // polls whether anything is ready on the read buffer - nothing happens until there's something there
+  {
+    incoming = SerialUSB.read();
+    // after data received, send the same back
+    SerialUSB.println(incoming);
+
+    // measure start time - then acquire data for an amount of time set by the acquisition_time variable
+    unsigned long start_micros = micros();
+    unsigned long start_time = millis();
+
+    // generate and concatenate strings
+    for (int jj = 0; jj < buffer_length; jj++)
+    {
+
+      // ADC acquisition
+
+      // can put this in a small loop for some averaging if required - takes ~ 60 microsec per read/concatenate cycle
+      while((ADC->ADC_ISR & 0x80)!=0x80); // wait for conversion to complete - see page 1345 of datasheet
+
+      // concatenate strings
+      current_time = micros()-start_micros;
+      strTime.concat(current_time); // time axis
+      strTime.concat(',');
+      strC1.concat(ADC->ADC_CDR[7]); // read data from the channel data register
+      strC1.concat(',');
+
+      //Serial.print(current_time);
+      //Serial.print(",");
+
+      delayMicroseconds(sampling_time_sleep); // limit sampling rate to something reasonable - a few kS/s
+    }
+
+    // send data via SerialUSB
+    // perform a flush first to wait for the previous buffer to be sent, before overwriting it
+    SerialUSB.flush();
+    strOut = strTime + strC1;
+    SerialUSB.print(strOut); // doesn't wait for write to complete before moving on
+
+
+    // clear string data - re-initialise
+    strTime = "";
+    strC1 = "";
+
+
+    // finally, print end-of-data and end-of-line character to signify no more data will be coming
+    SerialUSB.println("\0");
+
+  }
+}


Delete main.ino

Delete main.ino

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/bitinstitute/irobot.git/'


Create PC_v099b0325.ino

Create PC_v099b0325.ino

add channel id to particle publish msg

error: pathspec 'Particle' did not match any file(s) known to git
error: pathspec 'Photon' did not match any file(s) known to git
error: pathspec 'based/code/PC_v099b0325.ino' did not match any file(s) known to git


added tone piezo

added tone piezo

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/jeremywrnr/wampum.git/'


Vetor de objetos com voto

Vetor de objetos com voto

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/ciandt-dev/garage-kelvin-celsius.git/'


Add reading inputs

Add reading inputs

error: pathspec 'ArduinoSW/Laser-harp/Laser-harp.ino' did not match any file(s) known to git

--- ArduinoSW/Laser-harp/Laser-harp.ino
+++ ArduinoSW/Laser-harp/Laser-harp.ino
@@ -0,0 +1,129 @@
+// První oktáva
+int laserIN01 = 21;
+int laserIN02 = 22;
+int laserIN03 = 23;
+int laserIN04 = 24;
+int laserIN05 = 25;
+int laserIN06 = 26;
+int laserIN07 = 27;
+int laserIN08 = 28;
+
+// Druhá oktáva
+int laserIN09 = 29;
+int laserIN10 = 30;
+int laserIN11 = 31;
+int laserIN12 = 32;
+int laserIN13 = 33;
+int laserIN14 = 34;
+int laserIN15 = 35;
+int laserIN16 = 36;
+
+// Třetí oktáva
+int laserIN17 = 37;
+int laserIN18 = 38;
+int laserIN19 = 39;
+int laserIN20 = 40;
+int laserIN21 = 41;
+int laserIN22 = 42;
+int laserIN23 = 43;
+int laserIN24 = 44;
+
+
+// První oktáva
+int laser01;
+int laser02;
+int laser03;
+int laser04;
+int laser05;
+int laser06;
+int laser07;
+int laser08;
+
+// Druhá oktáva
+int laser09;
+int laser10;
+int laser11;
+int laser12;
+int laser13;
+int laser14;
+int laser15;
+int laser16;
+
+// Třetí oktáva
+int laser17;
+int laser18;
+int laser19;
+int laser20;
+int laser21;
+int laser22;
+int laser23;
+int laser24;
+
+
+int oktava1[8] = {laser01, laser02, laser03, laser04, laser05, laser06, laser07, laser08};
+int oktava2[8] = {laser09, laser10, laser11, laser12, laser13, laser14, laser15, laser16};
+int oktava3[8] = {laser17, laser18, laser19, laser20, laser21, laser22, laser23, laser24};
+
+
+void setup() {
+  Serial.begin(9600);
+  pinMode(laserIN01, INPUT);
+  pinMode(laserIN02, INPUT);
+  pinMode(laserIN03, INPUT);
+  pinMode(laserIN04, INPUT);
+  pinMode(laserIN05, INPUT);
+  pinMode(laserIN06, INPUT);
+  pinMode(laserIN07, INPUT);
+  pinMode(laserIN08, INPUT);
+
+  pinMode(laserIN09, INPUT);
+  pinMode(laserIN10, INPUT);
+  pinMode(laserIN11, INPUT);
+  pinMode(laserIN12, INPUT);
+  pinMode(laserIN13, INPUT);
+  pinMode(laserIN14, INPUT);
+  pinMode(laserIN15, INPUT);
+  pinMode(laserIN16, INPUT);
+
+  pinMode(laserIN17, INPUT);
+  pinMode(laserIN18, INPUT);
+  pinMode(laserIN19, INPUT);
+  pinMode(laserIN20, INPUT);
+  pinMode(laserIN21, INPUT);
+  pinMode(laserIN22, INPUT);
+  pinMode(laserIN23, INPUT);
+  pinMode(laserIN24, INPUT);
+}
+
+void loop() {
+
+oktava1[0] = digitalRead(laserIN01);
+oktava1[1] = digitalRead(laserIN02);
+oktava1[2] = digitalRead(laserIN03);
+oktava1[3] = digitalRead(laserIN04);
+oktava1[4] = digitalRead(laserIN05);
+oktava1[5] = digitalRead(laserIN06);
+oktava1[6] = digitalRead(laserIN07);
+oktava1[7] = digitalRead(laserIN08);
+
+oktava2[0] = digitalRead(laserIN09);
+oktava2[1] = digitalRead(laserIN10);
+oktava2[2] = digitalRead(laserIN11);
+oktava2[3] = digitalRead(laserIN12);
+oktava2[4] = digitalRead(laserIN13);
+oktava2[5] = digitalRead(laserIN14);
+oktava2[6] = digitalRead(laserIN15);
+oktava2[7] = digitalRead(laserIN16);
+
+oktava3[0] = digitalRead(laserIN17);
+oktava3[1] = digitalRead(laserIN18);
+oktava3[2] = digitalRead(laserIN19);
+oktava3[3] = digitalRead(laserIN20);
+oktava3[4] = digitalRead(laserIN21);
+oktava3[5] = digitalRead(laserIN22);
+oktava3[6] = digitalRead(laserIN23);
+oktava3[7] = digitalRead(laserIN24);
+
+
+
+}


First commit

First commit

error: pathspec '_74HC595_Controller/_74HC595_Controller.ino' did not match any file(s) known to git

--- _74HC595_Controller/_74HC595_Controller.ino
+++ _74HC595_Controller/_74HC595_Controller.ino
@@ -0,0 +1,81 @@
+int SER_Pin = 8;   //pin 14 on the 75HC595
+int RCLK_Pin = 9;  //pin 12 on the 75HC595
+int SRCLK_Pin = 10; //pin 11 on the 75HC595
+
+//How many of the shift registers - change this
+#define number_of_74hc595s 1
+
+//do not touch
+#define numOfRegisterPins number_of_74hc595s * 8
+
+boolean registers[numOfRegisterPins];
+
+void setup(){
+  pinMode(SER_Pin, OUTPUT);
+  pinMode(RCLK_Pin, OUTPUT);
+  pinMode(SRCLK_Pin, OUTPUT);
+
+
+  //reset all register pins
+  clearRegisters();
+  writeRegisters();
+}
+
+
+//set all register pins to LOW
+void clearRegisters(){
+  for(int i = numOfRegisterPins - 1; i >=  0; i--){
+     registers[i] = LOW;
+  }
+}
+
+
+//Set and display registers
+//Only call AFTER all values are set how you would like (slow otherwise)
+void writeRegisters(){
+
+  digitalWrite(RCLK_Pin, LOW);
+
+  for(int i = numOfRegisterPins - 1; i >=  0; i--){
+    digitalWrite(SRCLK_Pin, LOW);
+
+    int val = registers[i];
+
+    digitalWrite(SER_Pin, val);
+    digitalWrite(SRCLK_Pin, HIGH);
+
+  }
+  digitalWrite(RCLK_Pin, HIGH);
+
+}
+
+//set an individual pin HIGH or LOW
+void setRegisterPin(int index, int value){
+  registers[index] = value;
+}
+
+
+void loop(){
+
+  setRegisterPin(0, HIGH);
+  setRegisterPin(1, HIGH);
+  setRegisterPin(2, HIGH);
+  setRegisterPin(3, HIGH);
+  setRegisterPin(4, HIGH);
+  setRegisterPin(5, HIGH);
+  setRegisterPin(6, HIGH);
+  setRegisterPin(7, HIGH);
+  writeRegisters();
+  delay(1000);
+
+  setRegisterPin(0, LOW);
+  setRegisterPin(1, LOW);
+  setRegisterPin(2, LOW);
+  setRegisterPin(3, LOW);
+  setRegisterPin(4, LOW);
+  setRegisterPin(5, LOW);
+  setRegisterPin(6, LOW);
+  setRegisterPin(7, LOW);
+  writeRegisters();
+  delay(1000);
+}


Created first Arduino transmitter test program.

error: pathspec 'arduino/test/tx_test/tx_test.ino' did not match any file(s) known to git

--- arduino/test/tx_test/tx_test.ino
+++ arduino/test/tx_test/tx_test.ino
@@ -0,0 +1,20 @@
+// One Arduino controls transmitters on pins 3 and 11, alternately
+// sending out pings from the two of them, simulating two synchronized
+// transmitter stations sending out pings in turn.
+
+enum {
+  tx_pin_1 = 3,
+  tx_pin_2 = 11,
+};
+
+void setup() {
+  pinMode(tx_pin_1, OUTPUT);
+  pinMode(tx_pin_2, OUTPUT);
+}
+
+void loop() {
+  tone(tx_pin_1, 25000u, 1u);
+  delay(100u);
+  tone(tx_pin_2, 25000u, 1u);
+  delay(1000u);
+}


Flashing rather than fading blue and orange LEDs

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/csgregg/maker.git/'


Create InterleavedContinuous.ino

Create InterleavedContinuous.ino

error: pathspec 'examples/InterleavedContinuous.ino' did not match any file(s) known to git

--- examples/InterleavedContinuous.ino
+++ examples/InterleavedContinuous.ino
@@ -0,0 +1,69 @@
+/* This example demonstrates how to use interleaved mode to
+take continuous range and ambient light measurements. The
+datasheet recommends using interleaved mode instead of
+running "range and ALS continuous modes simultaneously (i.e.
+asynchronously)".
+
+In order to attain a faster update rate (10 Hz), the max
+convergence time for ranging and integration time for
+ambient light measurement are reduced from the normally
+recommended defaults. See section 2.4.4 ("Continuous mode
+limits") and Table 6 ("Interleaved mode limits (10 Hz
+operation)") in the VL6180X datasheet for more details.
+
+Raw ambient light readings can be converted to units of lux
+using the equation in datasheet section 2.13.4 ("ALS count
+to lux conversion").
+
+Example: A VL6180X gives an ambient light reading of 613
+with the default gain of 1 and an integration period of
+50 ms as configured in this sketch (reduced from 100 ms as
+set by configureDefault()). With the factory calibrated
+resolution of 0.32 lux/count, the light level is therefore
+(0.32 * 613 * 100) / (1 * 50) or 392 lux.
+
+The range readings are in units of mm. */
+
+#include <Wire.h>
+#include <VL6180X.h>
+
+VL6180X sensor;
+
+void setup()
+{
+  Wire.begin();
+
+  sensor.init();
+  sensor.configureDefault();
+
+  // Reduce range max convergence time and ALS integration
+  // time to 30 ms and 50 ms, respectively, to allow 10 Hz
+  // operation (as suggested by Table 6 ("Interleaved mode
+  // limits (10 Hz operation)") in the datasheet).
+  sensor.writeReg(VL6180X::SYSRANGE__MAX_CONVERGENCE_TIME, 30);
+  sensor.writeReg16Bit(VL6180X::SYSALS__INTEGRATION_PERIOD, 50);
+
+  sensor.setTimeout(500);
+
+   // stop continuous mode if already active
+  sensor.stopContinuous();
+  // in case stopContinuous() triggered a single-shot
+  // measurement, wait for it to complete
+  delay(300);
+  // start interleaved continuous mode with period of 100 ms
+  sensor.startInterleavedContinuous(100);
+
+}
+
+void loop()
+{
+  Serial.print("Ambient: ");
+  Serial.print(sensor.readAmbientContinuous());
+  if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }
+
+  Serial.print("\tRange: ");
+  Serial.print(sensor.readRangeContinuous());
+  if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }
+
+  Serial.println();
+}


Update mappings

Update mappings

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/mvines/futboard.git/'


Added an example of using the AS5055 chip found on the arduino forums

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/10to7/AS5055A_Nema17_Breakout.git/'


vl53L0x test

vl53L0x test

error: pathspec 'testing/arduino/VL53L0X/VL53L0X.ino' did not match any file(s) known to git

--- testing/arduino/VL53L0X/VL53L0X.ino
+++ testing/arduino/VL53L0X/VL53L0X.ino
@@ -0,0 +1,44 @@
+#include <Wire.h>
+#include <VL53L0X.h>
+
+VL53L0X Sensor1;
+VL53L0X Sensor2;
+
+const uint8_t Sensor1_xshut = 4;
+const uint8_t Sensor2_xshut = 5;
+
+const uint8_t Sensor1_address = 22;
+const uint8_t Sensor2_address = 25;
+
+void setup()
+{
+  pinMode(Sensor1_xshut, OUTPUT);
+  pinMode(Sensor2_xshut, OUTPUT);
+  digitalWrite(Sensor1_xshut, LOW);
+  digitalWrite(Sensor2_xshut, LOW);
+
+  Wire.begin();
+  Serial.begin (9600);
+
+  pinMode(Sensor1_xshut, INPUT);
+  Sensor1.init(true);
+  Sensor1.setAddress(Sensor1_address);
+  Sensor1.setTimeout(500);
+  Sensor1.startContinuous();
+
+  pinMode(Sensor2_xshut, INPUT);
+  Sensor2.init(true);
+  Sensor2.setAddress(Sensor2_address);
+  Sensor2.setTimeout(500);
+  Sensor2.startContinuous();
+}
+
+void loop()
+{
+  Serial.println(Sensor1.readRangeContinuousMillimeters());
+  Serial.println(Sensor2.readRangeContinuousMillimeters());
+
+  //if (Sensor1.timeoutOccurred()) { Serial.print(" TIMEOUT"); }
+
+  Serial.println("---");
+}


Updated Files

Updated Files

error: pathspec 'IA-2/ia2output.ino' did not match any file(s) known to git

--- IA-2/ia2output.ino
+++ IA-2/ia2output.ino
@@ -0,0 +1,110 @@
+// This #include statement was automatically added by the Particle IDE.
+#include "neopixel/neopixel.h"
+
+/*
+ * This is a minimal example, see extra-examples.cpp for a version
+ * with more explantory documentation, example routines, how to
+ * hook up your pixels and all of the pixel types that are supported.
+ *
+ */
+
+
+SYSTEM_MODE(AUTOMATIC);
+
+// IMPORTANT: Set pixel COUNT, PIN and TYPE
+#define PIXEL_PIN D2
+#define PIXEL_COUNT 24
+#define PIXEL_TYPE WS2812B
+
+Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
+
+// Prototypes for local build, ok to leave in for Build IDE
+void rainbow(uint8_t wait);
+uint32_t Wheel(byte WheelPos);
+
+
+int led2 = D7;
+
+
+void setup()
+{
+
+   Serial.begin(9600);
+   pinMode(led2, OUTPUT);
+   Particle.function("led",ledToggle);
+   digitalWrite(led2, LOW);
+
+   strip.begin();
+   strip.setBrightness(2);
+   strip.show(); // Initialize all pixels to 'off'
+   uint16_t i;
+   uint32_t noColor=strip.Color(0,0,0); //noColor
+   for(i=0; i<24; i++)
+        {
+            strip.setPixelColor(i, noColor);
+            strip.show();
+        }
+}
+
+void loop()
+{
+
+}
+
+
+int ledToggle(String command) {
+
+    Serial.print("Got command: ");
+    Serial.println(command);
+
+    uint16_t i, j;
+    uint32_t red=strip.Color(255,0,0); //red
+    uint32_t green=strip.Color(0, 255, 0); //green
+    uint32_t blue=strip.Color(0,0,255); //blue
+    uint32_t noColor=strip.Color(0,0,0); //noColor
+
+    if (command=="red") {
+        digitalWrite(led2,HIGH);//check photon connection
+        for(i=0; i<24; i++) // 24 is the number of pixels; we use this instead of strip.numPixels
+        {
+            strip.setPixelColor(i, red);
+            strip.show();
+        }
+        Serial.print("Game");
+        return 1;
+    }
+     else if (command=="green") {
+        digitalWrite(led2,HIGH);//check photon connection
+        for(i=0; i<24; i++)
+        {
+            strip.setPixelColor(i, green);
+            strip.show();
+        }
+        Serial.print("People");
+        return 1;
+    }
+    else if (command=="blue") {
+        digitalWrite(led2,HIGH);//check photon connection
+        for(i=0; i<24; i++)
+        {
+            strip.setPixelColor(i, blue);
+            strip.show();
+        }
+        Serial.print("No Data");
+        return 1;
+    }
+    else if (command=="off") {
+        digitalWrite(led2,LOW);
+        for(i=0; i<24; i++)
+        {
+            strip.setPixelColor(i, noColor);
+            strip.show();
+        }
+        Serial.print("Switching off LED");
+        return 0;
+    }
+    else {
+        return -1;
+    }
+
+}


saymon_says

error: pathspec 'saymon_says/saymon_says.ino' did not match any file(s) known to git

--- saymon_says/saymon_says.ino
+++ saymon_says/saymon_says.ino
@@ -0,0 +1,148 @@
+//saymon says http://it.wikipedia.org/wiki/Simon_(gioco)
+#include "pitches.h"
+
+#include <SPI.h>
+#include <Wire.h>
+#include <Adafruit_GFX.h>
+#include <Adafruit_SSD1306.h>
+
+#define OLED_MOSI   9
+#define OLED_CLK   10
+#define OLED_DC    11
+#define OLED_CS    12
+#define OLED_RESET 13
+Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
+
+const int redLed = 7;
+const int greenLed = 6;
+const int yellowLed = 5;
+const int blueLed = 4;
+
+const int tonePin = 8;
+
+const int redButton = 3;
+const int greenButton = 2;
+const int yellowButton = 1;
+const int blueButton = 0;
+const int maxLength = 100; //max level
+const int statePrepare = 0;
+const int statePlay = 1;
+const int stateEnd = 2;
+
+int lastRedButtonValue;
+int sequenceLength;
+int state;
+int sequence[maxLength];
+int currentPlayingSeqIndex;
+
+void setup() {
+  Serial.begin(9600);
+
+  display.begin(SSD1306_SWITCHCAPVCC);
+  pinMode(redLed, OUTPUT);
+  pinMode(greenLed, OUTPUT);
+  pinMode(yellowLed, OUTPUT);
+  pinMode(blueLed, OUTPUT);
+
+  pinMode(redButton, INPUT);
+  digitalWrite(redButton, LOW);
+  pinMode(greenButton, INPUT);
+  digitalWrite(greenButton, LOW);
+  pinMode(yellowButton, INPUT);
+  digitalWrite(yellowButton, LOW);
+  pinMode(blueButton, INPUT);
+  digitalWrite(blueButton, LOW);
+
+  sequenceLength = 1;
+  state = statePrepare;
+
+  randomSeed(analogRead(A5));
+}
+
+void loop() {
+
+  if (state == statePrepare) {
+    //set
+    for (int i = 0; i < sequenceLength; i++) {
+      int button = random(4);
+      if (button == 0) sequence[i] = redButton;
+      if (button == 1) sequence[i] = greenButton;
+      if (button == 2) sequence[i] = yellowButton;
+      if (button == 3) sequence[i] = blueButton;
+    }
+
+    //play
+    diplayWrite("memorizza");
+    for (int i = 0; i < sequenceLength; i++) {
+    int button = sequence[i];
+      delay(300);
+      digitalWrite(button, HIGH);
+      if (button == redButton) { tone(tonePin, NOTE_C4); digitalWrite(redLed, HIGH); }
+      if (button == greenButton) { tone(tonePin, NOTE_D4); digitalWrite(greenLed, HIGH); }
+      if (button == yellowButton) { tone(tonePin, NOTE_E4); digitalWrite(yellowLed, HIGH); }
+      if (button == blueButton) { tone(tonePin, NOTE_F4); digitalWrite(blueLed, HIGH); }
+
+      delay(1000);
+      noTone(tonePin);
+      allLedOff();
+
+    }
+    state = statePlay;
+    diplayWrite("ripeti");
+    currentPlayingSeqIndex = 0;
+
+  }
+
+
+  if (pressed(redButton) && (state == statePlay)) {
+     checkPressing(redLed, NOTE_C4, redButton);
+  } else if (pressed(greenButton) && (state == statePlay)) {
+    checkPressing(greenLed, NOTE_D4, greenButton);
+  } else if (pressed(yellowButton) && (state == statePlay)) {
+    checkPressing(yellowLed, NOTE_E4, yellowButton);
+  } else if (pressed(blueButton) && (state == statePlay)) {
+    checkPressing(blueLed, NOTE_F4, blueButton);
+  }
+
+
+}
+
+void checkPressing(int led, unsigned int note, int button) {
+       digitalWrite(led, HIGH);
+       tone(tonePin, note);
+       if (sequence[currentPlayingSeqIndex] == button) {
+         diplayWrite("OK !");
+         currentPlayingSeqIndex ++;
+       } else {
+         diplayWrite("sbagliato");
+         state = stateEnd;
+       }
+      delay(1000);
+      noTone(tonePin);
+      allLedOff();
+
+}
+
+void allLedOff() {
+  digitalWrite(redLed, LOW);
+  digitalWrite(greenLed, LOW);
+  digitalWrite(yellowLed, LOW);
+  digitalWrite(blueLed, LOW);
+}
+
+boolean pressed(int button) {
+  delay(10);
+  return digitalRead(button) == HIGH;
+}
+
+
+void diplayWrite(char* text) {
+  display.clearDisplay();
+  display.setTextSize(4);
+  display.setTextColor(WHITE);
+  display.setCursor(0,0);
+  display.print(text);
+  display.display();
+}
+
+