วันอังคารที่ 12 กุมภาพันธ์ พ.ศ. 2562


งานที่11


ปฏิบัติงานที่11
Codeโปรแกรมงาน
#include "LedControl.h"
#define C4 262 #define D4 294
#define G4 392
#define E4 330 #define F4 349 #define A4 440
int melody[] = {C4,D4,E4,F4,G4,A4,B4,C5};
#define B4 494 #define C5 523
int timestop = 70;
float beats[] ={1,1,1,1,1,1,1,1}; int buzzerpin = 11;
// Pin 8->DIN, 10->CLK, 9->CS(LOAD), 1 = No.of devices
LedControl lc=LedControl(8,10,9,1); void setup() { lc.shutdown(0,false);
pinMode(buzzerpin,OUTPUT);
lc.setIntensity(0,5); lc.clearDisplay(0); int dl = 500; int numnote;
tone(buzzerpin, melody[i],dl*beats[i]);
numnote = sizeof(melody)/2; for (int i=0;i<numnote;i++) { lc.setChar(0,7-i,'-',false);
}
delay(dl*beats[i]); digitalWrite(buzzerpin,HIGH); delay(timestop); } } void loop()
{




ไม่มีความคิดเห็น:

แสดงความคิดเห็น