I'm in desperate need of help for my eksamensprojekt

I have made a program with the little knowlegde i have from programming in a java program and i do get alot of mistakes that i don't know how to fix. I have asked my teacher and he doesn't know enough about it for some reason (seems kinda under qualified since he should be the one to help us with this stuff). If anyone could tell me where to find the information i need or tell me what to do to fix this.

Thanks in advance

New: My teacher told me to use this (public static void main(String[] args) i don't really know what it does.
I changed the text into english so it would be easier for you to understand.
Our product is a machine that can make a protein shake for the user after his or her preferences.
I will keep changing this as i read the comments.

(some of this stuff is in danish but that shouldn't make a difference since it should only names and text)

#include <Stepper.h>
const int stepsPerRevolution = 200;

int LillePumpe = 10; // jp3 //
int StorPumpe = 9; // jp4 //
int Enable = 4; //Enable pin til stepmotoren//
Stepper myStepper(stepsPerRevolution, 1,2,5,6); //stepmotoren//

void setup() {
pinMode(Enable, OUTPUT);
pinMode(LillePumpe, OUTPUT);
pinMode(StorPumpe, OUTPUT);
Serial.begin(9600);
myStepper.setSpeed(35);
Keyboard.begin();
}

digitalWrite(Enable, HIGH);
digitalWrite(LillePumpe, LOW);
digitalWrite(StorPumpe, LOW);

void loop (){

public static void main(String[] args) {

if (Serial.available() > 0) {
char inChar = Serial.read();
Keyboard.write(inChar+1);
}

Serial.println("Type your weight in kilo grams and press return.");

int WeightInKilograms = 0;

WeightInKilograms = Keyboard.nextInt();

Serial.println("type 1 if you are training endurance training (for example running or cycling) or type 2 if you are training strength training (for example Bodybuilding, weightlifting or 100-meter-running) and press return.");

int WorkoutType = 0;

WorkoutType = Keyboard.nextInt();

Serial.println("type 1 for a mix with water or type 2 for a mix with milk and press return.");

int TypeOfMixture = 0;

TypeOfMixture = Keyboard.nextInt();

Serial.println("Type 1 for a thin max, type 2 for a medium mix or type 3 for a thick mix and press return.");

int ThicknessOfMixture = 0;

ThicknessOfMixture = Keyboard.nextInt();

if (WorkOutType = 1){
myStepper.step(WeightInKilograms * 3,333);
}
if (WorkOutType = 2){
myStepper.step(WeightInKilograms * 8,444);
}
if (WeightInKilograms >= 135){
myStepper.step(1,111);
}

if (TypeOfMixture == 1 && ThicknessOfMixture == 1){
digitalWrite(LillePumpe, HIGH);
delay(500);
digitalWrite(LillePumpe, LOW);
}
if (TypeOfMixture == 1 && ThicknessOfMixture == 2){
digitalWrite(LillePumpe, HIGH);
delay(1000);
digitalWrite(LillePumpe, LOW);
}
if (TypeOfMixture == 1 && ThicknessOfMixture == 3){
digitalWrite(LillePumpe, HIGH);
delay(2000);
digitalWrite(LillePumpe, LOW);
}
if (TypeOfMixture == 2 && ThicknessOfMixture == 1){
digitalWrite(StorPumpe, HIGH);
delay(500);
digitalWrite(StorPumpe, LOW);
}
if (TypeOfMixture == 2 && ThicknessOfMixture == 2){
digitalWrite(StorPumpe, HIGH);
delay(1000);
digitalWrite(StorPumpe, LOW);
}
if (TypeOfMixture == 2 && ThicknessOfMixture == 3){
digitalWrite(StorPumpe, HIGH);
delay(2000);
digitalWrite(StorPumpe, LOW);
}

Serial.println("Shake you're shake thoroughly for about 2 minutes.");
}
}

Hi please read this link, then edit your post to format the sketch, ie using # code tags.

http://forum.arduino.cc/index.php?topic=148996.0

Also explain what you are attempting to do, and how, that way we will be able to help with your project.
Hope to help.

Tom.... :slight_smile:

You've got code that isn't in a function, two functions called "setup", something called a "testatur" which isn't defined, I have absolutely no idea what this public static void main(String[] args) (note the use of code tags there) is, and you have assignments where you should have comparisons.

I'm astonished you managed to write so much without attempting to compile it.

You can only have one 'void setup()'. Combine the two, and you may want to include the code inbetween the two too.

Hi

Start by making a new sketch/program.
First make sure you are able to output something.
Compile and test.
Then try to read a value.
Compile and test.
Then try to control the stepper motor.
Compile and test.
And so on and so on.
That way you verify that you get all the little pieces to work before you attempt to put it all into the final solution.
This makes it much easier to locate and fix errors.

" if (TypeOfMixture = 1 & ThicknessOfMixture = 1)"
I assume you are attempting to check to values here.
What you actually is doing is assigning two values and do a bit operation.
The correct syntax is:
if (TypeOfMixture == 1 && ThicknessOfMixture == 1){

TEK73:
That way you verify that you get all the little pieces to work before you attempt to put it all into the final solution.

+1

This is the only way to make progress - even if you are an expert.

...R

Robin2:

TEK73:
That way you verify that you get all the little pieces to work before you attempt to put it all into the final solution.

+1
This is the only way to make progress - even if you are an expert.

  • another 1. And that way, you learn by your (small) mistakes as you go along.

Send me a message where u descr. WHAT u want to do. and HOW u think solving it.
(på dansk/norsk)