햇살 가득한 절벽 길이 키 큰 황금빛 풀 사이로 구불구불 이어진다. 아래로
Wikiprompt, 무료 프롬프트 백과사전에서
햇살 가득한 절벽 길이 키 큰 황금빛 풀 사이로 구불구불 이어진다. 아래로 아두이노 스케치를 생성하기 위한 프롬프트로, LDR 센서와 서보 모터를 사용한 2축 태양 추적 장치를 위한 것으로, 특정 핀 할당과 제어 로직을 포함합니다.
프롬프트 내용저장
🌐
#include <Servo.h>
Servo horizontalServo;
Servo verticalServo;
const int LDR_TOP_LEFT = A0;
const int LDR_TOP_RIGHT = A1;
const int LDR_BOTTOM_LEFT = A2;
const int LDR_BOTTOM_RIGHT = A3;
const int HORIZONTAL_SERVO_PIN = 9;
const int VERTICAL_SERVO_PIN = 10;
const int tolerance = 20;
const int horizontalMin = 10;
const int horizontalMax = 170;
const int verticalMin = 10;
const int verticalMax = 80;
int horizontalPos = 90;
int verticalPos = 45;
void setup() {
horizontalServo.attach(HORIZONTAL_SERVO_PIN);
verticalServo.attach(VERTICAL_SERVO_PIN);
horizontalServo.write(horizontalPos);
verticalServo.write(verticalPosipse);
delay(1000);
}
void loop() {
int tl = analogRead(LDR_TOP_LEFT);
int tr = analogRead(LDR_TOP_RIGHT);
int bl = analogRead(LDR_BOTTOM_LEFT);
int br = analogRead(LDR_BOTTOM_RIGHT);
int topAvg = (tl + tr) / 2;
int bottomAvg = (bl + br) / 2;
if (bottomAvg - topAvg > tolerance) {
verticalPos++;
} else if (topAvg - bottomAvg > tolerance) {
verticalPos--;
}
verticalPos = constrain(verticalPos, verticalMin, verticalMax);
int leftAvg = (tl + bl) / 2;
int rightAvg = (tr + br) / 2;
if (leftAvg - rightAvg > tolerance) {
horizontalPos--;
} else if (rightAvg - leftAvg > tolerance) {
horizontalPos++;
}
horizontalPos = constrain(horizontalPos, horizontalMin, horizontalMax);
verticalServo.write(verticalPos);
horizontalServo.write(horizontalPos);
delay(50);
}
전체 프롬프트를 보려면 로그인하세요
Continue with:
By logging in, you agree to our Terms of Use and Privacy Policy
사용법
이 프롬프트는 coding와 함께 사용하도록 설계되었습니다. 위의 프롬프트 내용을 복사하여 원하는 AI 도구에 붙여넣으세요.
최상의 결과를 얻으려면 자리 표시자(대괄호 또는 대문자로 표시)를 특정 요구 사항으로 사용자 지정할 수 있습니다.
토론
댓글 0개