2 digit output

Hey guys,

as a beginner im stumbelling on a early problem. Im trying to let my arduino uno read a lm35 temperature sensor and make him output the degrees in a led setup.

whats happening now is that it works from degrees 1-9 perfectly, but the second you have 2 digits it doesnt work. It wil see anything between 10-19 as 1, 20-29 as 2 and so on.

how can i let my arduino send a digital output that is 2 digit in stead of one?

Much thanks in advance

how can i let my arduino send a digital output that is 2 digit in stead of one?

Fix line 22.

im sorry but im not sure what you mean with “fix line 22”.
could you elaborate a bit more?

thank you

could you elaborate a bit more?

There are guidelines for posting in this forum. Clearly, you haven't read them. Go do so now. When you are done, you'll know what you left out of your post.

well i did read them, but im not sure where to paste the code as its a big one. ill try to put it under my main post.

unfortunatley it has to much characters in it to post. is there a standard way to handle 2 digit codes?

ive tried many diffrent approaches wich include storing 2 bytes and then combining them with a forumula, but they have all failed so far.

Does anyone have a wortking sample to combine 2 bytes together? Thanks for your Patience

ill try to put it under my main post.

Don't ever go back and edit your original post like that, if you expect people to actually help you.

Im guessing first post is what a person would read when they read my post for the first time. that would be the logical place to put the code or am i mistaken.

Yes, you are mistaken.

well i did read them, but im not sure where to paste the code as its a big one.

So, when you read the posting guidelines, you no doubt read the part that said you could attach your code to a post, or you could break the code down to the smallest size that still exhibited the problem.

that would be the logical place to put the code or am i mistaken.

If you put your code in the first post, now, I look like a fool for complaining that you failed to post code. If you try to make me look like a fool, where is my incentive to help you?

Allright,

My apologogies.

It is in no way my intention to make anyone look bad.
Im new and not sure how or what is the way of doing here.

i can understand you guys get tired from people not knowing what they are doing,
but the hostilitie levels are kinda high for a new guy posting here.

void loop()
{
while (Serial.available() == 0);
int val =Serial.read();
Serial.println(val);
  
switch (val){

I know this part of the code is wrong in all means, but it Does let me use 1-9 digits perfectly.
the seconde i hang a formula on it like this one it fails and its still 1 digit only

void loop() {
  // Get 8 samples of temperature
  for(i = 0; i<=7; i++){
    samples[i] = ( 5.0 * analogRead(sensorPin) * 100.0) / 1024.0;
    tempc = tempc + samples[i];
    delay(50);
  }
  tempc = tempc/8.0;

Post all your code.

but the hostilitie levels are kinda high for a new guy posting here.

Is it so hard to follow a few simple guidelines designed to get you answers as quickly as possible?

okay…

Temperatuur_tot_9.ino (12.9 KB)

switch (val){

case '1':  
     if (val == 1);

I gave up looking right there

okay.

all i ever needed to know is the loop part. so its 2 numbers in stead of 1.

im pretty sure you guys know how to do it, and all i wanted was an example how to calculate 1 byte + 1 byte.

I am new to the whole arduino. but ya thanks for your your attempt.

Your temperature code doesn't appear in the code you posted.

i used this code before.

void loop() {
  // Get 8 samples of temperature
  for(i = 0; i<=7; i++){
    samples[i] = ( 5.0 * analogRead(sensorPin) * 100.0) / 1024.0;
    tempc = tempc + samples[i];
    delay(50);
  }
  tempc = tempc/8.0; //

i used this code before.

But that doesn't display anything, so can't be relevant to the discussion here.

If you're asking "How do I input multi-digit numbers?" that's a different question, but one which comes up here about once a week (more frequently at assignment hand-in time), so a short search will give you your answer.

The 500-odd lines you posted earlier should be about 30 lines of code, with sensible use of loops and arrays.

The set up is just as followed,

arduino gets analog input from a temperature sensor. and for each degree a combination of led will light up.

its has 9 leds. 1/4 have a value of 1, 5 has a value of 5, and 6/7/8 have a value of 10.

The whole problem is that i have used multiple codes before and all have failed. i get the correct degree on my computer, but sending the info to the corrosponding leds is not working.

This is all a hobby, so all things i use or see are based on some internet tips or tricks.

Im pretty aware the 500 line thing is a monster for an expert to look at. but for my simple basic thing programming its the only think i could invent at the moment.

The set up is just as followed,

That is NOT what the code you attached earlier does.

PLEASE post the exact code you are describing.

Sorry Awol,

that with the 500 lines was the code i was trying to use for it.

i appreciate your help and time. but just delete my whole post.

clearly i know not enough about adruino to be able to pull this off. i dont want to waste your time trying to bend ur mind over my lack of knowledge.

all i needed was that my adruino said 20 in stead of saying 2 and then 0

Thanks for your patience and advice.