Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MPR121 mbed Servo
main.cpp
00001 #include "mbed.h" 00002 #include "Servo.h" 00003 #include <mpr121.h> 00004 #include "SongPlayer.h" 00005 00006 #define max_note 40 00007 #define max_timer_seconds 20 00008 #define A2 110.0 00009 #define B2 123.0 00010 #define C3 131.0 00011 #define D3 185.0 00012 #define E3 165.0 00013 #define F3 174.614 00014 #define G3 195.998 00015 #define G_# 207.652 00016 00017 uint8_t mode = 0; 00018 DigitalIn record_mode(p14); 00019 DigitalIn play_back_mode(p16); 00020 DigitalIn play_live_mode(p15); 00021 DigitalIn STOP(p17); 00022 DigitalOut GreenLED(p18); 00023 DigitalOut IndicatorLED(p19); 00024 DigitalIn RESET(p20); 00025 I2C i2c(p9, p10); 00026 00027 Mpr121 mpr121(&i2c, Mpr121::ADD_VSS); 00028 InterruptIn interrupt(p30); 00029 Servo skull_jaw(p26); 00030 Servo skull_base(p25); 00031 Servo spare_servo(p24); 00032 PwmOut RED_LED(p23); 00033 PwmOut Blue_LED(p22); 00034 SongPlayer mySpeaker(p21); 00035 00036 bool expired; //Timer expiration 00037 00038 //Instantiate Skull Object 00039 00040 class skull{ 00041 public: 00042 char memory[40]; 00043 void openJaw(float angle); 00044 void turn_table(float angle); 00045 void play_tune(float tune); 00046 void record_memory(); 00047 void erase_memory(); 00048 void append_memory(); 00049 }; 00050 00051 int main() { 00052 while(1) { 00053 if(record_mode == 1){ 00054 mode = 1; 00055 } 00056 if(play_back_mode == 1){ 00057 mode = 2; 00058 } 00059 if(play_live_mode == 1){ 00060 mode = 3; 00061 } 00062 if(STOP == 1){ 00063 mode = 4; 00064 } 00065 switch(mode){ 00066 case 1: 00067 //Record Mode 00068 break; 00069 case 2: 00070 //Play_back_mode 00071 break; 00072 case 3: 00073 //play_live_mode 00074 break; 00075 case 4: 00076 //Stop 00077 break; 00078 case 5: 00079 //Reset 00080 break; 00081 } 00082 } 00083 } 00084 00085 void fallInterrupt() { 00086 //int key_code=0; 00087 //int i=0; 00088 if(mode == 1 && !expired){ 00089 //write the recorded stuff here 00090 } //recording mode 00091 00092 if(mode == 2){ 00093 uint16_t value=mpr121.read(0x00); 00094 value +=mpr121.read(0x01)<<8; 00095 float note[] = {value + 110}; 00096 float duration[] = {0.24}; 00097 if(note[0]>110){ 00098 mySpeaker.PlaySong(note, duration);} 00099 } 00100 }
Generated on Sun Jul 17 2022 02:58:27 by
1.7.2