필터 지우기
필터 지우기

Blink LEDs using arduino!!

조회 수: 7 (최근 30일)
Khaled Al-Faleh
Khaled Al-Faleh 2017년 4월 18일
답변: Nick 2017년 4월 25일
Hi guys, I want to make like this code using matlab ...
void loop() {
for (int thisPin = 2; thisPin < 8; thisPin++) {
digitalWrite(thisPin, HIGH);
delay(500);
digitalWrite(thisPin, LOW);
}
but the problem is the matlab has this format and you can not change the pins in loop see this
writeDigitalPin(arduino, 'D2', 1);
Here I can only change the pins manually but how I can make like above code in loop which the pin change every time ..

채택된 답변

Nick
Nick 2017년 4월 25일
Hi
You can use num2str() and change the number during every loop. I tested using Matlab R2016a with this code and LEDs hooked up an Arduino on pins 3-5.
for i = 3:5
writeDigitalPin(a, ['d' num2str(i)] , 1)
pause(1)
writeDigitalPin(a, ['d' num2str(i)], 0)
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Support Package for Arduino Hardware에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by