필터 지우기
필터 지우기

How to turn on a GPIO (Raspberry Pi 4B) for one second

조회 수: 2 (최근 30일)
Nitesh Ramdin
Nitesh Ramdin 2020년 11월 24일
편집: Nitesh Ramdin 2020년 11월 24일
Hi
I am currently building a Raspberry pi autonomous using Mathlab neural network. I am using a Pi camera to capture images. Once an image is captured, with either a forward, left or right output command.
How do i go about turning on the string(label) on for one second only.
I could maybe turn on the forward for one second and implement a stop command to all the pins.
I am a begginer at this and need some direction.
Here is my code as below:
%% Algorithm rev2
for i = 1:1
img = snapshot(cam);
% Preproccessing`````````````````````
imgNew = imresize(img,[227 227]); % resize image
[YPred,probs] = classify(trainedNetwork_1,imgNew);
figure(1);
imshow(imgNew)
label = YPred;
title(string(label) + ", " + num2str(100*max(probs),3) + "%");
end
if string(label) == "Forward"%fwd
for W = 1:1
writeDigitalPin(mypi, 5, 1);
writeDigitalPin(mypi, 6, 0);
writeDigitalPin(mypi, 27, 1);
writeDigitalPin(mypi, 22, 0);
pause(0.5);
end
elseif string(label) == "Left"%pivotleft
for Y = 1:1
writeDigitalPin(mypi, 5, 0);
writeDigitalPin(mypi, 6, 1);
writeDigitalPin(mypi, 27, 1);
writeDigitalPin(mypi, 22, 0);
pause(0.5);
end
elseif string(label) == "Right"%pivotleft
for Z = 1:1
writeDigitalPin(mypi, 5, 0);
writeDigitalPin(mypi, 6, 1);
writeDigitalPin(mypi, 27, 1);
writeDigitalPin(mypi, 22, 0);
pause(0.5);
end
end

답변 (0개)

카테고리

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

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by