Skip to content

Instantly share code, notes, and snippets.

@haru01
Created September 3, 2016 22:05
Show Gist options
  • Save haru01/71b2c839e423aa44eee56f8288ea493a to your computer and use it in GitHub Desktop.
Save haru01/71b2c839e423aa44eee56f8288ea493a to your computer and use it in GitHub Desktop.
タッチで音
#include <stdint.h>
#include <SeeedTouchScreen.h>
#define YP A2 // must be an analog pin, use "An" notation!
#define XM A1 // must be an analog pin, use "An" notation!
#define YM 14 // can be a digital pin, this is A0
#define XP 17 // can be a digital pin, this is A3
#define TS_MINX 116*2
#define TS_MAXX 890*2
#define TS_MINY 83*2
#define TS_MAXY 913*2
TouchScreen ts = TouchScreen(XP, YP, XM, YM);
#include <Tone.h>
#include "Ultrasonic.h"
Tone notePlayer;
Ultrasonic ultrasonic(7);
int t = 0;
int pitch = 0;
void setup(void) {
Serial.begin(9600);
notePlayer.begin(8);
}
void loop(void) {
Point p = ts.getPoint();
if (p.z > __PRESURE) {
t = map(p.y, TS_MINY, TS_MAXY, 100, 1000) + map(p.x, TS_MINX, TS_MAXX, 100, 500);
}
notePlayer.play(t, 50);
delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment