戻る

更新バージョン

変更点
1)臨海融合頻度の最低頻度をコード内で指定(ここでは10Hz)
2)常に点灯しているLED(2つのGreenLEDの左側)を追加し、頻度を変えるLEDとの比較ができるようにした。

4 digit 7 segment displayでは、CLKはD9、DICはD8。常時ONのLEDはD3、CFF用のLEDはD2。頻度増加ボタンはD4、減少ボタンはD5とした。

PictBlox Code Download

//This c++ code is generated by PictoBlox

//Included Libraries
#include <TM1637Display.h>

//MACROS are defined here
TM1637Display display(9, 8);

//Gloabl Variables are declared here
float min_frequency;
float freq;
float onoff;

void setup() {
	//put your setup code here, to run once:
	pinMode(3, OUTPUT);
	display.setBrightness(0x0f);
	pinMode(4, INPUT);
	pinMode(5, INPUT);
	pinMode(2, OUTPUT);
	
	
	min_frequency = 10;
	freq = min_frequency;
	onoff = 1;
	digitalWrite(3, true);
	display.showNumberDecEx(freq, 0, 0, 4, 1 - 1);
}

void loop() {
	//put your main code here, to run repeatedly:
	
	
	if(digitalRead(4)) {
		freq = (freq + 1);
		display.showNumberDecEx(freq, 0, 0, 4, 1 - 1);
		delay(0.2 * 1000);
	}
	else {
		if(digitalRead(5)) {
			freq = (freq - 1);
			if((freq < min_frequency)) {
				freq = min_frequency;
			}
			display.showNumberDecEx(freq, 0, 0, 4, 1 - 1);
			delay(0.2 * 1000);
		}
		else {
			onoff = (0.5 / freq);
			digitalWrite(2, true);
			delay(onoff * 1000);
			digitalWrite(2, false);
			delay(onoff * 1000);
		}
	}
}

以下は前バージョン

写真の拡大

PictBlox Code Download

PictoBlox Code 拡大画像

//This c++ code is generated by PictoBlox

//Included Libraries
#include <TM1637Display.h>

//MACROS are defined here
TM1637Display display(9, 8);

//Gloabl Variables are declared here
float freq;
float onoff;
float switch1;
float switch2;

void setup() {
	//put your setup code here, to run once:
	display.setBrightness(0x0f);
	pinMode(1, INPUT);
	pinMode(2, INPUT);
	pinMode(2, OUTPUT);
	
	
	freq = 1;
	onoff = 1;
	display.showNumberDecEx(freq, 0, 0, 4, 1 - 1);
}

void loop() {
	//put your main code here, to run repeatedly:
	
	
	switch1 = analogRead(1);
	switch2 = analogRead(2);
	if((switch1 > 100)) {
		freq = (freq + 1);
		display.showNumberDecEx(freq, 0, 0, 4, 1 - 1);
		delay(0.2 * 1000);
	}
	else {
		if((switch2 > 100)) {
			if((freq < 2)) {
				freq = 2;
			}
			freq = (freq - 1);
			display.showNumberDecEx(freq, 0, 0, 4, 1 - 1);
			delay(0.2 * 1000);
		}
		else {
			onoff = (0.5 / freq);
			digitalWrite(2, true);
			delay(onoff * 1000);
			digitalWrite(2, false);
			delay(onoff * 1000);
		}
	}
}