Help with CE-cod

Hello :slight_smile: We are two girls from Sweden who needs some help with our School-project. We are going to use a Peltier to control a glass outside temperature. We only have a Pseudo-cod at the moment but need help with the CE-cod. So if you have any clue, please help us :slight_smile:

Pseudo-cod

-start up
-messure the temperature
-write temperatur i Serial monitor

  • write the temperature you want in Serial monitor

  • if the temp is wrong

  • the peltier starts to cool the glass

  • write the current temp in Serial monitor every second

  • when the temp is correct, LED on

  • hold the correct temp

(We have started with putting the Peltier in DIGITAL 3, Temperatur sensing ANALOG A0)

What part of converting the pseudecode to real code are you having problems with? What code have you currently got? What does it do that it shouldn't? What does it not do that it should?

We have started with putting the Peltier in DIGITAL 3

We have started by trying to fry the Arduino. That is NOT a good start.

I don't know what you mean by "CE" here.

This project seems very similar in that it uses a control loop to control a peltier:

You seem to be using on/off control (sometimes called bang-bang) rather than proportional control with PWM.

I would recommend using proportional control - a peltier switched off conducts heat extremely well so cannot
maintain a temperature difference, its best to drive it continuously and adjust the current.

Thanks for responding so fast!

We don't have any CE-cod at the moment. But this i a cod we found on a similar project. You think we can you parts of it?

int peltier = 3;
int temp = A0;
int power = 0;
int peltier_level = map (power, 0, 99, 0, 255);

void setup() {
Serial.begin(9600);
pinMode (peltier, OUTPUT);
} pinMode (temp, INPUT);

void loop() {
if (Serial.available

int reading = analogRead(temp); // temp

float voltage = reading * 5.0; // temp
voltage /= 1024.0; //temp

float temperatureC = (voltage - 0.5) * 100 ; //temp
Serial.print(temperatureC); Serial.println(" grader C"); // temp
delay(1000); //temp

}

Perhaps - but its probably more logical to start with breaking down the task of writingyour code into small pieces:

One piece controls the peltier.
One piece reads the temperature, converting to centigrade (or whatever you use),
One piece has the logic for controlling everything (it uses the other two).

Test each piece separately and build upwards - try to understand how existing code samples work
and which bits are doing each task.

You think we can you parts of it?

Not until it at least compiles. When you can make the code compile, use the parts that do what you want (and understand). Throw the rest away.

Your project is incredibly simple. There is NO part of your project that requires serial input.

We're glad to here that it's a simple project even tho we don't think that a the moment haha :wink:

If we need to write done a cod for each thing, which part should we start with? Controlling the Peltier? :confused: We don't have any knowledge with programming and arduino since before...

Many thanks!! / Julia and Matilda :slight_smile:

There is NO part of your project that requires serial input.

It is not entirely clear but they seem to want to be able to enter the target temperature.

  • write the temperature you want in Serial monitor
  • if the temp is wrong
  • the peltier starts to cool the glass

Personally I would write it first with a fixed target temperature, which is easy, then add the user input if it is required.

Julmat:
We're glad to here that it's a simple project even tho we don't think that a the moment haha :wink:

If we need to write done a cod for each thing, which part should we start with? Controlling the Peltier? :confused: We don't have any knowledge with programming and arduino since before...

Many thanks!! / Julia and Matilda :slight_smile:

Start with whatever seems easiest, and for which you have the hardware, and if necessary experiment
a bit - but keep researching similar projects, you will find out lots of useful tips and tricks eventually.