Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
B basis
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • m242
  • basis
  • Wiki
  • speaker

Last edited by stephan.metzler Dec 10, 2018
Page history
This is an old version of this page. You can view the most recent version or browse the history.

speaker

Ausgangslage

  • Ereignisse haben Audio-Effekte
    • Bumber, Flips, etc.

Bedingungen

  • sinvolle Datentypen verwenden

Aufbau

  • Seeeduino V4.2
    • als Arduino UNO programmieren
    • nicht als "Seeeduino V4.2"
  • Input
    • Wii Nunchuck - I2C Two-Wire Peripheral Interface
    • RTC - I2C Two-Wire Peripheral Interface
  • Output
    • Speaker für die Audio-Effekte
      als digiteler Output #define SPEAKER 3 ansteuerbar
    • Led - D8

Handlungsziele

Vorgehen Hannok Handlungsnotwendige Kenntnisse
Töne, Frequenzen PWM
Tonfolgen erzeugen Array, Iteration
sinnvolle Datentypen Array of byte
Testbarkeit Loggen, ASSERT

Code Sample

#define SPEAKER 3

int BassTab[] = {1911, 1702, 1516, 1431, 1275, 1136, 1012}; // bass 1~7

void setup() {
  pinMode(SPEAKER, OUTPUT);
  digitalWrite(SPEAKER, LOW);
}

void loop() {
  for (int note_index = 0; note_index < 7; note_index++) {
    sound(note_index);
    delay(50);
  }
}

void sound(uint8_t note_index) {
  for (int i = 0; i < 100; i++) {
    digitalWrite(SPEAKER, HIGH);
    delayMicroseconds(BassTab[note_index]);
    digitalWrite(SPEAKER, LOW);
    delayMicroseconds(BassTab[note_index]);
  }
}

Code Sample RTC

#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);
}
void printTime() {               // Function: Display time on the serial monitor
  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("Wednesday");
      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(" ");
}
Clone repository
  • flipper project
  • Home
  • interrupt
  • lcd
  • led bar
  • led ring
  • led stick
  • nunchuck
  • rfid rc522
  • speaker
  • testen
  • wifi
  • workshops