program matrix1
dim colonnes, hazards as byte[8]
dim x, vitesse as byte
main:
ADCON0 = %00000001 ADCON1 = %00001110 TrisA = %00000001 TrisB = %00000000 TrisC = %00000000 TrisD = %00000000 TrisE = %00000000 PortA = %00000000 PortB = %00000000 PortC = %00000000 PortD = %00000000 PortE = %00000000 while true
PortB = colonnes[0]
PortD = %00000001
ADCON0.GO = 1
delay_ms(1)
hazards[0] = hazards[0] + ADRESL + PCL
PortB = colonnes[1]
PortD = %00000010
ADCON0.GO = 1
delay_ms(1)
hazards[1] = hazards[1] + ADRESL + PCL
PortB = colonnes[2]
PortD = %00000100
ADCON0.GO = 1
delay_ms(1)
hazards[2] = hazards[2] + ADRESL + PCL
PortB = colonnes[3]
PortD = %00001000
ADCON0.GO = 1
delay_ms(1)
hazards[3] = hazards[3] + ADRESL + PCL
PortB = colonnes[4]
PortD = %00010000
ADCON0.GO = 1
delay_ms(1)
hazards[4] = hazards[4] + ADRESL + PCL
PortB = colonnes[5]
PortD = %00100000
ADCON0.GO = 1
delay_ms(1)
hazards[5] = hazards[5] + ADRESL + PCL
PortB = colonnes[6]
PortD = %01000000
ADCON0.GO = 1
delay_ms(1)
hazards[6] = hazards[6] + ADRESL + PCL
PortB = colonnes[7]
PortD = %10000000
ADCON0.GO = 1
delay_ms(1)
hazards[7] = hazards[7] + ADRESL + PCL
inc(vitesse)
if vitesse = 31 then
colonnes[0]=colonnes[0]<<1
colonnes[1]=colonnes[1]<<1
colonnes[2]=colonnes[2]<<1
colonnes[3]=colonnes[3]<<1
colonnes[4]=colonnes[4]<<1
colonnes[5]=colonnes[5]<<1
colonnes[6]=colonnes[6]<<1
colonnes[7]=colonnes[7]<<1
x = hazards[0] mod 7
if x = 0 then colonnes[0].0 = 1 end if
x = hazards[1] mod 7
if x = 0 then colonnes[1].0 = 1 end if
x = hazards[2] mod 7
if x = 0 then colonnes[2].0 = 1 end if
x = hazards[3] mod 7
if x = 0 then colonnes[3].0 = 1 end if
x = hazards[4] mod 7
if x = 0 then colonnes[4].0 = 1 end if
x = hazards[5] mod 7
if x = 0 then colonnes[5].0 = 1 end if
x = hazards[6] mod 7
if x = 0 then colonnes[6].0 = 1 end if
x = hazards[7] mod 7
if x = 0 then colonnes[7].0 = 1 end if
vitesse = 0
end if
wend
end.