kusakari_motor
Toggle main menu visibility
読み取り中…
検索中…
一致する文字列を見つけられません
driver_test2.ino
[詳解]
1
#define PIN_DIR 7
2
#define PIN_PWM 5
3
#define PIN_VOL A0
4
5
void
setup
() {
6
// put your setup code here, to run once:
7
Serial.begin(9600);
8
9
pinMode(
PIN_DIR
, OUTPUT);
10
pinMode(
PIN_PWM
, OUTPUT);
11
analogWrite(
PIN_PWM
, 0);
12
}
13
14
void
loop
() {
15
// put your main code here, to run repeatedly:
16
int
time_data = millis();
17
18
if
((time_data % 1000) == 0) {
19
int
second = time_data / 1000;
20
Serial.print(second);
21
}
22
23
int
value = analogRead(
PIN_VOL
);
//0 to 1023
24
float
value_ = float(value) / 1023 * 255 * 0.75;
//0 to 255 * 0.75
25
int
pwm = int(value_);
26
Serial.print(
"Value: "
);
27
Serial.print(value);
28
Serial.print(
" pwm: "
);
29
Serial.println(pwm);
30
digitalWrite(
PIN_DIR
, LOW);
31
analogWrite(
PIN_PWM
, pwm);
32
33
}
PIN_PWM
#define PIN_PWM
定義
driver_test2.ino:2
setup
void setup()
定義
driver_test2.ino:5
PIN_VOL
#define PIN_VOL
定義
driver_test2.ino:3
PIN_DIR
#define PIN_DIR
定義
driver_test2.ino:1
loop
void loop()
定義
driver_test2.ino:14
driver_test2.ino
構築:
1.18.0