Ви не увійшли.
Сторінки 1
Да спасибо
Вибило ошибку при компиляции
rduino: 1.8.5 (Windows 7), Плата:"Arduino/Genuino Uno"
sketch_jul30c:1: error: stray '\315' in program
const int btn_2 = 3Нѕ
^
sketch_jul30c:1: error: stray '\276' in program
sketch_jul30c:2: error: stray '\315' in program
const int buzz = 4Нѕ
^
sketch_jul30c:2: error: stray '\276' in program
sketch_jul30c:3: error: stray '\315' in program
byte val_2 = 0Нѕ
^
sketch_jul30c:3: error: stray '\276' in program
sketch_jul30c:4: error: stray '\315' in program
bool state = falseНѕ
^
sketch_jul30c:4: error: stray '\276' in program
sketch_jul30c:6: error: stray '\315' in program
const int btn_1 = 2Нѕ
^
sketch_jul30c:6: error: stray '\276' in program
sketch_jul30c:7: error: stray '\315' in program
byte val_1 = 0Нѕ
^
sketch_jul30c:7: error: stray '\276' in program
sketch_jul30c:10: error: stray '\315' in program
pinMode(btn_2, INPUT)Нѕ
^
sketch_jul30c:10: error: stray '\276' in program
sketch_jul30c:11: error: stray '\315' in program
pinMode(buzz, OUTPUT)Нѕ
^
sketch_jul30c:11: error: stray '\276' in program
sketch_jul30c:13: error: stray '\315' in program
pinMode(btn_1, INPUT)Нѕ
^
sketch_jul30c:13: error: stray '\276' in program
sketch_jul30c:17: error: stray '\315' in program
val_2 = digitalRead(btn_2)Нѕ
^
sketch_jul30c:17: error: stray '\276' in program
sketch_jul30c:18: error: stray '\315' in program
if( val_2 == 1){ state = trueНѕ val_1 = 0; }
^
sketch_jul30c:18: error: stray '\276' in program
sketch_jul30c:20: error: stray '\315' in program
val_1 = digitalRead(btn_1)Нѕ
^
sketch_jul30c:20: error: stray '\276' in program
sketch_jul30c:21: error: stray '\315' in program
if( val_1 == 1){ state = falseНѕ val_2 = 0; }
^
sketch_jul30c:21: error: stray '\276' in program
sketch_jul30c:25: error: stray '\315' in program
digitalWrite(buzz, HIGH)Нѕ
^
sketch_jul30c:25: error: stray '\276' in program
sketch_jul30c:27: error: stray '\315' in program
digitalWrite(buzz, LOW)Нѕ
^
sketch_jul30c:27: error: stray '\276' in program
sketch_jul30c:2: error: expected ',' or ';' before 'const'
const int buzz = 4Нѕ
^
C:\Users\z\Documents\Arduino\sketch_jul30c\sketch_jul30c.ino: In function 'void loop()':
sketch_jul30c:17: error: 'val_2' was not declared in this scope
val_2 = digitalRead(btn_2)Нѕ
^
sketch_jul30c:20: error: 'val_1' was not declared in this scope
val_1 = digitalRead(btn_1)Нѕ
^
sketch_jul30c:20: error: 'btn_1' was not declared in this scope
val_1 = digitalRead(btn_1)Нѕ
^
sketch_jul30c:24: error: 'state' was not declared in this scope
if( state == true){
^
sketch_jul30c:25: error: 'buzz' was not declared in this scope
digitalWrite(buzz, HIGH)Нѕ
^
sketch_jul30c:27: error: 'buzz' was not declared in this scope
digitalWrite(buzz, LOW)Нѕ
^
exit status 1
stray '\315' in program
Этот отчёт будет иметь больше информации с
включенной опцией Файл -> Настройки ->
"Показать подробный вывод во время компиляции"
Как сделать так чтобы нажав и отпустив первую кнопку диод горел, а после нажатия второй гас
Для развития, хочу знать как
Как в эту програму добавить вторую кнопку чтобы она отменяла действие первой кнопкой
const int btn = 3;
const int buzz = 4;
byte val = 0;
bool state = 0;
void setup() {
pinMode(btn, INPUT);
pinMode(buzz, OUTPUT);
}
void loop() {
val = digitalRead(btn);
if( val == HIGH){
state = !state;
delay(200);
}
if( state == true){
digitalWrite(buzz, HIGH);
} else {
digitalWrite(buzz, LOW);
}
}
Большое вам спасибо очень помогли
Спасибі диод нечел гореть но нет плавного виключення и включення
Не работает схема
int brightness = 0;
int fadeAmount = 5;
unsigned long currentTime;
unsigned long loopTime ;
void setup(){
pinMode(10, OUTPUT);
currentTime = millis();
loopTime = currentTime;
}
void loop(){
if(currentTime >= (loopTime +20)){
analogWrite(10, brightness);
brightness = brightness + fadeAmount;
if(brightness == 0 || brightness == 255){
fadeAmount = -fadeAmount;
}
loopTime = currentTime;
}
}
Сторінки 1