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.
Diff: main.cpp
- Revision:
- 7:725b3bc34e7e
- Parent:
- 6:e3ed48abbd53
- Child:
- 8:ce5b480a2646
--- a/main.cpp Fri Jul 22 11:44:22 2016 +0000
+++ b/main.cpp Fri Jul 22 13:26:16 2016 +0000
@@ -4,6 +4,8 @@
PwmOut mypwm(PC_8);
DigitalIn sw(USER_BUTTON);
+#define sound_duty 0.1
+
bool flip_flag;
void flip()
@@ -26,9 +28,28 @@
if(flip_flag == 1) {
+ //のこぎり波
if(sw == 0) data = ft;
- else data = sin(6.28 * ft) + 1;
-
+
+ //のこぎり波、下り
+ //else data = 1 - ft;
+
+ //正弦波
+ //else data = sin(6.28 * ft) + 1;
+ //三角波
+
+ else {
+ if(ft < sound_duty) data = ft * (1 / sound_duty);
+ else data = (1 / (1 - sound_duty)) * (1 - ft);
+ }
+
+ //矩形波
+ /*
+ else{
+ if(ft < sound_duty) data = 1;//thをいじればduty変わりそう
+ else data = 0;
+ }
+ */
mypwm.write( data / 20 );
ft += late * freq_out;