bonjour suite a deux projet (horloge anneau ring et bouton sens delay)
j'ai les deux code qui marche indépendamment mes ensemble pas avec plusieurs erreur j'ai corriger une grande partie mes pour le rest j'ai besoin d'aide
le code de l'horloge seul
#include <Wire.h>
#include <RTClib.h>
#include <Adafruit_NeoPixel.h>
#define PIN 13
#define PIXEL 60
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL, PIN, NEO_GRB + NEO_KHZ800);
RTC_DS1307 RTC; // Establish clock object
DateTime Clock; // Holds current clock time
byte hourval, minuteval, secondval;
void setup() {
Serial.begin(9600);
Wire.begin(); // Begin I2C
RTC.begin(); // begin clock
if (! RTC.isrunning()) {
// Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
}
//RTC.adjust(DateTime(__DATE__, __TIME__));
strip.begin();
strip.show(); // Initialize all pixels to 'off'
strip.setBrightness(255);
}
void loop() {
Clock = RTC.now(); // get the RTC time
secondval = Clock.second(); // get seconds
minuteval = Clock.minute(); // get minutes
hourval = Clock.hour(); // get hours
if(hourval > 11) hourval -= 12; // This clock is 12 hour, if 13-23, convert to 0-11
hourval = (hourval*60 + minuteval) / 12;
strip.setPixelColor(hourval, 0x008080);strip.setPixelColor(hourval-1, 0x004040);strip.setPixelColor(hourval+1, 0x004040);
strip.setPixelColor(hourval-2, 0x001010);strip.setPixelColor(hourval+2, 0x001010);
strip.setPixelColor(minuteval, 0x800080);
strip.setPixelColor(minuteval-1, 0x200020);strip.setPixelColor(minuteval+1, 0x200020);
strip.setPixelColor(secondval, 0x808000);strip.setPixelColor(secondval-1, 0x002F00);strip.setPixelColor(secondval+1, 0x002F00);
strip.show();
strip.setPixelColor(hourval, 0x000000);strip.setPixelColor(hourval-1, 0x000000);strip.setPixelColor(hourval+1, 0x000000);
strip.setPixelColor(hourval-2, 0x000000);strip.setPixelColor(hourval+2, 0x000000);
strip.setPixelColor(minuteval, 0x000000);strip.setPixelColor(minuteval-1, 0x000000);strip.setPixelColor(minuteval+1, 0x000000);
strip.setPixelColor(secondval, 0x000000);strip.setPixelColor(secondval-1, 0x000000);strip.setPixelColor(secondval+1, 0x000000);
delay(25);
/*
Serial.print(hourval, DEC);
Serial.print(':');
Serial.print(minuteval, DEC);
Serial.print(':');
Serial.println(secondval, DEC);
*/
}
le code des bouton
/*
This is a sample sketch to show how to use the OneButtonLibrary
to detect click events on 2 buttons in parallel.
The library internals are explained at
http://www.mathertel.de/Arduino/OneButtonLibrary.aspx
Setup a test circuit:
* Connect a pushbutton to pin A1 (ButtonPin) and ground.
* Connect a pushbutton to pin A2 (ButtonPin) and ground.
* The Serial interface is used for output the detected button events.
The Sketch shows how to setup the library and bind 2 buttons to their functions.
In the loop function the button1.tick and button2.tick functions have to be called as often as you like.
*/
// 01.03.2014 created by Matthias Hertel
// ... and working.
/* Sample output:
Starting TwoButtons...
Button 1 click.
Button 2 click.
Button 1 doubleclick.
Button 2 doubleclick.
Button 1 longPress start
Button 1 longPress...
Button 1 longPress...
Button 1 longPress...
Button 1 longPress stop
Button 2 longPress start
Button 2 longPress...
Button 2 longPress...
Button 2 longPress stop
*/
#include "OneButton.h"
// Setup a new OneButton on pin A1.
OneButton button1(A1, true);
// Setup a new OneButton on pin A2.
OneButton button2(A2, true);
// setup code here, to run once:
void setup() {
// Setup the Serial port. see http://arduino.cc/en/Serial/IfSerial
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("Starting TwoButtons...");
// link the button 1 functions.
button1.attachClick(click1);
button1.attachDoubleClick(doubleclick1);
button1.attachLongPressStart(longPressStart1);
button1.attachLongPressStop(longPressStop1);
button1.attachDuringLongPress(longPress1);
} // setup
// main code here, to run repeatedly:
void loop() {
// keep watching the push buttons:
button1.tick();
// You can implement other code in here or just wait a while
delay(10);
} // loop
// ----- button 1 callback functions
// This function will be called when the button1 was pressed 1 time (and no 2. button press followed).
void click1() {
Serial.println("Button 1 click.");
} // click1
// This function will be called when the button1 was pressed 2 times in a short timeframe.
void doubleclick1() {
Serial.println("Button 1 doubleclick.");
} // doubleclick1
// This function will be called once, when the button1 is pressed for a long time.
void longPressStart1() {
Serial.println("Button 1 longPress start");
} // longPressStart1
// This function will be called often, while the button1 is pressed for a long time.
void longPress1() {
Serial.println("Button 1 longPress...");
} // longPress1
// This function will be called once, when the button1 is released after beeing pressed for a long time.
void longPressStop1() {
Serial.println("Button 1 longPress stop");
} // longPressStop1
le code des deux avec modification
(a la suite)