Offline
Edison Member
Karma: 3
Posts: 1712
|
 |
« Reply #45 on: February 04, 2012, 10:25:55 am » |
And the setup is the same, just declare the one wire bus pin and pass it to the dallas temin
|
|
|
|
|
Logged
|
|
|
|
|
Odense, Denmark
Offline
Full Member
Karma: 0
Posts: 168
|
 |
« Reply #46 on: February 04, 2012, 10:56:55 am » |
i Shamelessly ripped off a bit from that and adjusted my sketch... i have attached it as it is now.
i tried to make and OR thing:
{ if(Newtemp - Oldtemp > 5); { if(Newtemp1 - Oldtemp1 > 5) { Tempflag = 1; }
but i can see it will not work
i know && means AND.... but how do i make an OR ?
|
|
|
|
« Last Edit: February 04, 2012, 11:03:48 am by boelle »
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 3
Posts: 1712
|
 |
« Reply #47 on: February 04, 2012, 11:22:58 am » |
== means equal to && means and |means or
Id sugest to have a newtemp1 and newtemp2 and the same for old, and flag this way they operate independently otherwise if one triggers The other wont trigger
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 137
Posts: 19036
I don't think you connected the grounds, Dave.
|
 |
« Reply #48 on: February 04, 2012, 11:26:53 am » |
Putting semicolons on your if statements isn't going to help
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
New Jersey
Offline
Edison Member
Karma: 24
Posts: 2348
|
 |
« Reply #49 on: February 04, 2012, 11:36:49 am » |
== means equal to && means and |means or Typo? While that is true, logical or || is what is required here, not bitwise or |
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 3
Posts: 1712
|
 |
« Reply #50 on: February 04, 2012, 11:37:20 am » |
Yeah just noticed that typo now, was literally just gonna correct it
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 1
Posts: 164
http://www.open-electronics.org
|
 |
« Reply #51 on: February 04, 2012, 12:00:53 pm » |
|
|
|
|
|
Logged
|
|
|
|
|
Odense, Denmark
Offline
Full Member
Karma: 0
Posts: 168
|
 |
« Reply #52 on: February 04, 2012, 12:45:50 pm » |
hi.. i will return later... i'm freezing outside trying to figure out why car has so hard time starting.. must be due to -11 degree C right now and it dropping more later at night
|
|
|
|
|
Logged
|
|
|
|
|
Odense, Denmark
Offline
Full Member
Karma: 0
Posts: 168
|
 |
« Reply #53 on: February 04, 2012, 01:00:41 pm » |
while i thaw a bit i will adjust the sketch....
i did get the sketch examples from google but they do not suit my needs
|
|
|
|
|
Logged
|
|
|
|
|
Odense, Denmark
Offline
Full Member
Karma: 0
Posts: 168
|
 |
« Reply #54 on: February 04, 2012, 01:18:05 pm » |
i tried to adjust a bit but got some errors:
sketch_feb01b.cpp: In function 'void loop()': sketch_feb01b:136: error: expected primary-expression before '||' token sketch_feb01b:136: error: expected primary-expression before 'if' sketch_feb01b:136: error: expected `;' before 'if' sketch_feb01b:226: error: expected `}' at end of input sketch_feb01b:226: error: expected `}' at end of input
new sketch attached
|
|
|
|
|
Logged
|
|
|
|
|
Odense, Denmark
Offline
Full Member
Karma: 0
Posts: 168
|
 |
« Reply #55 on: February 04, 2012, 01:29:13 pm » |
i can get it to compile until i add: || if(Newtemp1 - Oldtemp1 > 5)
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 137
Posts: 19036
I don't think you connected the grounds, Dave.
|
 |
« Reply #56 on: February 04, 2012, 01:50:25 pm » |
Tha's not really surprising, because it is syntactically incorrect. ||if is not a recognized C construct. Tell us what you want to do.
Post code, even.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Odense, Denmark
Offline
Full Member
Karma: 0
Posts: 168
|
 |
« Reply #57 on: February 04, 2012, 02:47:10 pm » |
i did attach the sketch as post would grow to big for me to allow to post:
what i wanted was to make a if statement that in basic would look something like this:
if(Newtemp - Oldtemp > 5) OR if(Newtemp1 - Oldtemp1 > 5)
ie, if either one is true then trigger... it does not matter which one
|
|
|
|
|
Logged
|
|
|
|
|
New Jersey
Offline
Edison Member
Karma: 24
Posts: 2348
|
 |
« Reply #58 on: February 04, 2012, 03:41:40 pm » |
Your memory of basic has become rusty, however: if(((Newtemp - Oldtemp) > 5) || ((Newtemp1 - Oldtemp1) > 5)) { //do my stuff }
likely too many parens, didn't want to look up the precedence
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 3
Posts: 1712
|
 |
« Reply #59 on: February 04, 2012, 04:20:08 pm » |
Here's the below better written if(newtemp - oldtemp > 5 || newtemp1 - oldtemp1 > 5){ //dosomething }
sometimes the parenthesis is not needed : )
|
|
|
|
|
Logged
|
|
|
|
|
|