Я работаю над школьным проектом с очень небольшими ресурсами. Мне нужно сделать линию после робота, который находит путь через лабиринт, повернув налево, когда это возможно. У меня уже есть небольшое тело, но робот, похоже, не поворачивает налево/следуйте линии, когда это необходимо. Я также понятия не имею, как я могу избавиться от небольших отклонений и как я могу сделать поворот робота, когда нет линий?
Материалы:
arduino leonardo < /p>
< /li>
qtr-8a Датчик земли < / p>
< /li>
Два основных двигателя DC < /p>
< /li>
< /ul>
code:
#include //setup for motors
DRV8835MotorShield motors;
void setup() {
// put your setup code here, to run once:
motors.flipM1(true);
motors.flipM2(true);
}
void loop() {
//left groundsensor= analogRead(A0);
//rightgroundsensor = analogRead(A2);
//middlegroundsensor = analogRead(A1);
//motorstM1//right weel
//motors.setM2Speed(100);//left weel
if(analogRead(A0) > 750){ //turn left
motors.setM1Speed(100);
motors.setM2Speed(-100);
}
else if(analogRead(A1) > 750){//nothing left, so go straight
motors.setM1Speed(100);
motors.setM2Speed(100);
}
else if(analogRead(A2) > 750){//nothing in the middle, so robot has deviated, turn right a bit, if the deviation is to the rigth, I don't need the next loop
while(analogRead(A0) < 750){//turn right till black line is in the middle again
motors.setM1Speed(-100);
motors.setM1Speed(100);
}
}
else{//if they are all < 750, it's a deviation or a dead end, I will have to watch how the robot deviates so that I can turn let it always turn in the opposite direction
while(analogRead(A1) < 750){//turn right/left till black line is in the middle again
motors.setM1Speed(-100);
motors.setM1Speed(100);
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/724 ... n-carduino
Ардуно линия после робота для начинающих в C ++ (Arduino) ⇐ C++
Программы на C++. Форум разработчиков
-
Anonymous
1739124843
Anonymous
Я работаю над школьным проектом с очень небольшими ресурсами. Мне нужно сделать линию после робота, который находит путь через лабиринт, повернув налево, когда это возможно. У меня уже есть небольшое тело, но робот, похоже, не поворачивает налево/следуйте линии, когда это необходимо. Я также понятия не имею, как я могу избавиться от небольших отклонений и как я могу сделать поворот робота, когда нет линий?
[b] Материалы: [/b]
arduino leonardo < /p>
< /li>
qtr-8a Датчик земли < / p>
< /li>
Два основных двигателя DC < /p>
< /li>
< /ul>
[b] code: [/b]
#include //setup for motors
DRV8835MotorShield motors;
void setup() {
// put your setup code here, to run once:
motors.flipM1(true);
motors.flipM2(true);
}
void loop() {
//left groundsensor= analogRead(A0);
//rightgroundsensor = analogRead(A2);
//middlegroundsensor = analogRead(A1);
//motorstM1//right weel
//motors.setM2Speed(100);//left weel
if(analogRead(A0) > 750){ //turn left
motors.setM1Speed(100);
motors.setM2Speed(-100);
}
else if(analogRead(A1) > 750){//nothing left, so go straight
motors.setM1Speed(100);
motors.setM2Speed(100);
}
else if(analogRead(A2) > 750){//nothing in the middle, so robot has deviated, turn right a bit, if the deviation is to the rigth, I don't need the next loop
while(analogRead(A0) < 750){//turn right till black line is in the middle again
motors.setM1Speed(-100);
motors.setM1Speed(100);
}
}
else{//if they are all < 750, it's a deviation or a dead end, I will have to watch how the robot deviates so that I can turn let it always turn in the opposite direction
while(analogRead(A1) < 750){//turn right/left till black line is in the middle again
motors.setM1Speed(-100);
motors.setM1Speed(100);
}
}
}
Подробнее здесь: [url]https://stackoverflow.com/questions/72406797/arduino-line-following-robot-for-beginners-in-carduino[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия