Quantcast
Channel: MEL PICBASIC Forum
Viewing all articles
Browse latest Browse all 4787

Word variable and storing correct value

$
0
0
Code:

Fade:
    Vb_1 = ((B_Day_On_H - B_Dawn_On_H)*60)      ' difference between day start and dawn start hour, converted to min
    Vb_2 = (B_Day_On_M - B_Dawn_On_M)            ' difference between day start and dawn start mins
    Vb_5 = (Vb_1+Vb_2)*60                        ' Get total duration time in seconds
    Vb_6 = B_Max - B_Min                        ' Work out the 'distance' the lights go from min to max
    B_Fadein_Time = Vb_5 / Vb_6                  ' Get number of seconds between each PWM pulse   
    Vb_7 = Vb_5 // Vb_6                                                                'Get fractions of a second
    Vb_8 = B_Fadein_Time

 ' with B day on at 8:10 and a Dawn on at 8:00,  Vb1 = (8 - 8) * 60 which gives 0.  Vb2 = (10-0) = 10,  Vb5 = (0+10)*60 = 600
 ' Vb6 = 255-0 = 255
 ' so fadein time = 600/255 = 2.352941176470588
 ' Vb_8 therefore should equal 236

I need VB_8 to = 235 (rounding down the fadein time and removing the decimal) but can't work out how - can someone please point me in the right direction

Thanks

Malcolm

Viewing all articles
Browse latest Browse all 4787

Trending Articles