Hello i dont know if this is the right page to use but i am out of ideas. I have a exam coming up where i builded a smartcar using arduino to program. But i need a flowchart for the exam but i really dont know how to make it. Can someone help me?
This is the code
#include <SoftwareSerial.h>
#include <Servo.h>
SoftwareSerial bluetooth(10, 11); // RX, TX
Servo mijnServo; // Servo-object aanmaken
const int trigPin = 8; // Ultrasone sensor triggerpin
const int echoPin = 9; // Ultrasone sensor echopin
int motor1A = 2;
int motor1B = 3;
int motor2A = 4;
int motor2B = 7;
int ENA = 6;
int ENB = 5;
void setup() {
Serial.begin(9600);
bluetooth.begin(9600);
mijnServo.attach(12); // Servo aan pin 12 koppelen
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(motor1A, OUTPUT);
pinMode(motor1B, OUTPUT);
pinMode(motor2A, OUTPUT);
pinMode(motor2B, OUTPUT);
pinMode(ENA, OUTPUT);
pinMode(ENB, OUTPUT);
}
void loop() {
// Ultrasone sensor logica
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
long duration = pulseIn(echoPin, HIGH);
int distance = duration * 0.034 / 2;
if (distance <= 30) {
Serial.println("OBSTAKEL");
stopMotors();
} else {
// Als er geen obstakel is, draai de servo rechtsom
mijnServo.write(90); // Pas de gewenste positie aan
}
delay(10);
// Bluetooth-besturing logica
if (bluetooth.available() > 0) {
char command = bluetooth.read();
switch (command) {
case 'w':
moveForward();
break;
case 's':
moveBackward();
break;
case 'a':
turnLeft();
break;
case 'd':
turnRight();
break;
case '0':
stopMotors();
break;
default:
break;
}
}
}
void moveForward() {
digitalWrite(motor1A, HIGH);
digitalWrite(motor1B, LOW);
digitalWrite(motor2A, HIGH);
digitalWrite(motor2B, LOW);
analogWrite(ENA, 255);
analogWrite(ENB, 255);
}
void moveBackward() {
digitalWrite(motor1A, LOW);
digitalWrite(motor1B, HIGH);
digitalWrite(motor2A, LOW);
digitalWrite(motor2B, HIGH);
}
void turnLeft() {
digitalWrite(motor1A, HIGH);
digitalWrite(motor1B, LOW);
digitalWrite(motor2A, LOW);
digitalWrite(motor2B, HIGH);
}
void turnRight() {
digitalWrite(motor1A, LOW);
digitalWrite(motor1B, HIGH);
digitalWrite(motor2A, HIGH);
digitalWrite(motor2B, LOW);
}
void stopMotors() {
digitalWrite(motor1A, LOW);
digitalWrite(motor1B, LOW);
digitalWrite(motor2A, LOW);
digitalWrite(motor2B, LOW);
// Als er een obstakel is, stop de servo
mijnServo.write(0); // Pas de gewenste positie aan
}
This seven minutes video shows how to make a computer programming flowchart, describing the shapes you will use, the meaning of the shapes, how to draw the shapes and how to connect the shapes, in "MSword":
Imma watch that. Seven minutes seems like enough to get a good ways into flow chart drawing, so.
@bjornt6951 if using the computer is less than fun, pencil and paper work very well. I find that flowcharts are best drawn on the back of those large envelopes that calendars you stopped using in the 20th century come in the mail.
My BASIC programming instructor back in 1982 had us submit a flowchart prior to starting the code. We then submitted an updated flowchart with the final code. More times than not the final flowchart was twice the size compared to the original.
Since a significant amount of discussion about flowchart creation technology has occurred here, I would like to mention Mermaid:
This approach of using code to define flowcharts is really beneficial when it is part of the content of a Git repository, as is the case with many software projects.
The design of the Mermaid language syntax is terrible. However, for better or worse Mermaid has achieved dominance in the field, which makes any of the alternatives an inferior option due to being less well supported even if they are technically superior. For example, GitHub has native Mermaid support, including embedding in Markdown files.
When it comes to Mermaid's diagram generation, I have no complaints. I was frustrated at the lack of control over the exact layout (I was previously using the graphical design tool yEd where I had complete control), but in the end I get perfectly usable flowcharts with far less effort so I can accept them not matching my own personal aesthetic perfectly.
Mermaid lets you create diagrams and visualizations using text and code.
So… you want people trying to turn processes and algorithms into code, who are being asked to start with flowcharts, to use a tool which requires use of a programming-like language, which you say sucks in some way, to produce nice looking flowcharts?
I wonder if anyone making nice charts with Mermaid starts by flow-charting what she'll need to write in the code.
I can't imagine a better waste of time.
If you know programming and want to make nice flowcharts, maybe it is a tool to look at. If you don't know anything, it seems like some very deep water to toss someone towards.
Pencil and paper and a seven minute quick start on flowcharts seems like a better path.
I many cases I would agree completely. However, people are already suggesting software applications. At least for the several of those I have experience with, the learning curve was equal or steeper than that of Mermaid and the long term payoff was far less.
If you are someone just trying to make a one-off project with no interest in regularly creating flow charts then by all means just use a pencil. In this case, I'm not so sure. This is someone taking a class with a focus on flowcharts, which indicates to me that it might be more than a one-off thing. Or maybe not, only @bjornt6951 could answer that.
Thank you for confirming my understanding. Any effort put in to make that work, for someone who is at the beginning of learning how to program the Arduino in C++, is a wasteful waste of a sidetrack.
Don't you remember not eating this kind of thing for breakfast? It's like trying to learn German and Chinese at the same time.
And I would respectfully disagree with that advice for noobs.
Hardly. It seemed more like a "let's do this fun thing first" kinda thing to me.
I think most things - writing prose, making schematics, drawing flowcharts and the like are best learned in some better than knowing nothing at all way using pencil and paper before using a software tool or even a typewriter is helpful.
A schematic drawing program will not teach you how to draw a schematic. Buying a typewriter will do nothing for your prose, and so forth.
That's my only claim. For all you experts out there, knock yourself out with Mermaid.
The Memraid code (which I have never used, but I will try) has made exactly the same (though not identical) Flow Chart as I have made in post #12 (Fig-2). However, the Memraid's Flow Chart of post #16 has the following limitations (to me):
1. The entry path to the Parallelogram from the Diamond should be at the trail side of the Parallelogram.
2. The exit path of the Parallelogram to the Diamond should be at the entry point (one of the horizontal corner points) of the Diamond.
3. The labels are not there.
Thank you for taking time to use Memraid to produce the Flow Chart from a "Textual Description".
Haven't used flowcharts since about 1990, despite being taught flowcharts in Computer Science degree, turns out few people in industry use them. (Kinda funny because industry always says they can't get grads with right skills, universities say "hey we taught them state of the art skills the professors learnt from 20 years ago, is that no good?").
Anyway, if I was using flowcharts nowadays, I would only do it if the drawing tool can also generate code, many of which can. For example http://www.flowgorithm.org/