This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// スイッチが押されたときにLEDを点滅させるプログラム | |
#define buttonPin 19 //INA:19 INB:14 | |
#define ledPin 5 //OUTA:5 OUTB:10 | |
bool buttonState = 0; | |
void setup() { | |
pinMode(ledPin, OUTPUT); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// モーターを360°回転させるプログラム | |
#include <Servo.h> //サーボモーターを動かす関数を用意します | |
#define moterPin 5 //OUTA:5 OUTB:10 | |
Servo myservo; | |
void setup() { | |
myservo.attach(moterPin,700,2300); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 光量値を示すプログラム(10kΩプルダウン、5V電源時) | |
#define cdsPin 1 | |
void setup() { | |
Serial.begin(9600); | |
pinMode(cdsPin, INPUT); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//* スイッチのON-OFFをシリアルモニターに表示するプログラム | |
#define buttonPin 12 | |
int buttonState = 0; | |
void setup() { | |
Serial.begin(9600); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pwmpin 3,5,6,9,10,11 | |
#define ledPin 3 | |
// 初期化 | |
void setup(){ | |
// LEDのピンを出力に |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 距離20cm以上だとLEDとブザー | |
#define ledPin 2 //LEDが2番ピン | |
#define buzzerPin 9 //ブザーが9番ピン | |
#define echoPin 11 //距離センサーの「echo」が11番ピン | |
#define trigPin 12 //距離センサーの「trig」が12番ピン | |
double Duration = 0; //受信した間隔 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 距離が10cmより小さくなるとLEDが光る | |
#define echoPin 11 //距離センサーの「echo」が11番ピン | |
#define trigPin 12 //距離センサーの「trig」が12番ピン | |
#define ledPin 2 //光が3番ピン | |
double Duration = 0; //受信した間隔 | |
double Distance = 0; //距離 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 電気を消すとLEDが光る | |
#define ledPin 2 //LEDが2番ピン | |
#define cdsPin 1 //光センサーが1番ピン | |
double Duration = 0; //受信した間隔 | |
double Distance = 0; //距離 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 電気が消え、かつスイッチが押されるとLEDがつく | |
#define cdsPin 1 //光センサーが1番ピン | |
#define buttonPin 12 //スイッチが12番ピン | |
#define ledPin 2 //LEDが2番ピン | |
bool buttonState = 0; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 距離20cm以内でスイッチが押されるとLEDが光り、ブザーも鳴る | |
#define ledPin 2 //LEDが2番ピン | |
#define buzzerPin 9 //ブザーが9番ピン | |
#define echoPin 5 //距離センサーの「echo」が5番ピン | |
#define trigPin 6 //距離センサーの「trig」が6番ピン |
OlderNewer