... | ... | @@ -11,6 +11,7 @@ |
|
|
* **nicht** den "Driver for Seeeduino V4.2" installieren
|
|
|
* Input
|
|
|
* [Wii Nunchuck](http://wiki.seeed.cc/Grove-NunChuck) - <code>I2C</code>
|
|
|
* [RTC](http://wiki.seeed.cc/Grove-RTC/) - <code>I2C</code>
|
|
|
* Output
|
|
|
* [Speaker](http://wiki.seeed.cc/Grove-Speaker) für die Audio-Effekte<br>
|
|
|
als digiteler Output <code>#define SPEAKER 3</code> ansteuerbar
|
... | ... | @@ -20,7 +21,7 @@ |
|
|
|
|
|
|Vorgehen|Hannok [Handlungsnotwendige Kenntnisse](https://cf.ict-berufsbildung.ch/modules.php?name=Mbk&a=20101&cmodnr=242&noheader=1)|
|
|
|
|:-------|:------|
|
|
|
| Töne, Frequenzen | PWM |
|
|
|
|Töne, Frequenzen | PWM |
|
|
|
|Tonfolgen erzeugen | Array, Iteration |
|
|
|
|sinnvolle Datentypen | Array of byte |
|
|
|
|Testbarkeit | Loggen, UART |
|
... | ... | @@ -55,3 +56,90 @@ void sound(uint8_t note_index) { |
|
|
|
|
|
```
|
|
|
|
|
|
# Code Sample RTC
|
|
|
```c
|
|
|
/****************************************************************************/
|
|
|
// Function: Set time and get the time from RTC chip(DS1307) and display
|
|
|
// it on the serial monitor.
|
|
|
// Hardware: Grove - RTC
|
|
|
// Arduino IDE: Arduino-1.0
|
|
|
// Author: FrankieChu
|
|
|
// Date: Jan 19,2013
|
|
|
// Version: v1.0
|
|
|
// by www.seeedstudio.com
|
|
|
//
|
|
|
// 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.
|
|
|
//
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
//
|
|
|
/****************************************************************************/
|
|
|
#include <Wire.h>
|
|
|
#include "DS1307.h"
|
|
|
|
|
|
DS1307 clock;//define a object of DS1307 class
|
|
|
void setup() {
|
|
|
Serial.begin(9600);
|
|
|
clock.begin();
|
|
|
clock.fillByYMD(2018, 2, 23); // Feb. 23,2013
|
|
|
clock.fillByHMS(8, 0, 0); // 08:00 00"
|
|
|
clock.fillDayOfWeek(FRI); // Friday
|
|
|
clock.setTime(); // write time to the RTC chip
|
|
|
}
|
|
|
void loop() {
|
|
|
printTime();
|
|
|
delay(1000);
|
|
|
}
|
|
|
/*Function: Display time on the serial monitor*/
|
|
|
void printTime()
|
|
|
{
|
|
|
clock.getTime();
|
|
|
Serial.print(clock.hour, DEC);
|
|
|
Serial.print(":");
|
|
|
Serial.print(clock.minute, DEC);
|
|
|
Serial.print(":");
|
|
|
Serial.print(clock.second, DEC);
|
|
|
Serial.print(" ");
|
|
|
Serial.print(clock.month, DEC);
|
|
|
Serial.print("/");
|
|
|
Serial.print(clock.dayOfMonth, DEC);
|
|
|
Serial.print("/");
|
|
|
Serial.print(clock.year + 2000, DEC);
|
|
|
Serial.print(" ");
|
|
|
Serial.print(clock.dayOfMonth);
|
|
|
Serial.print(" day of month is a ");
|
|
|
switch (clock.dayOfWeek) { // Friendly printout the weekday
|
|
|
case MON:
|
|
|
Serial.print("MONDAY");
|
|
|
break;
|
|
|
case TUE:
|
|
|
Serial.print("TUESDAY");
|
|
|
break;
|
|
|
case WED:
|
|
|
Serial.print("WEDNSDAY");
|
|
|
break;
|
|
|
case THU:
|
|
|
Serial.print("THURSDAY");
|
|
|
break;
|
|
|
case FRI:
|
|
|
Serial.print("FRIDAY");
|
|
|
break;
|
|
|
case SAT:
|
|
|
Serial.print("SATURDAY");
|
|
|
break;
|
|
|
case SUN:
|
|
|
Serial.print("SUNDAY");
|
|
|
break;
|
|
|
}
|
|
|
Serial.println(" ");
|
|
|
}
|
|
|
``` |
|
|
\ No newline at end of file |