-- DN009 : read bus_a_pin_0..3 as analog, show on LCD on bus_c -- hardware: DB016 + DB011 on bus_a + 2x16 LCD on BUS_C include DB016_18F252_PLL_40 include jdelay const LCD_lines = 2 include lcd_on_c bus_a_direction = all_input bus_b_direction = all_output bus_c_direction = all_output function hex( byte in x ) return byte is if x < 10 then return "0" + x else return ( "A" + x ) - 10 end if end function procedure show_channel( byte in channel ) is var byte result_1, result_0 adc_read_10( channel, result_1, result_0 ) LCD_Write( hex( result_1 & 0b_11 )) LCD_Write( hex( result_0 >> 4 )) LCD_Write( hex( result_0 & 0b_1111 )) end procedure procedure show( byte in n, byte in channel ) is LCD_Write( hex( n )) LCD_Write( ":" ) show_channel( channel ) end procedure LCD_Init LCD_Clear adc_configure( adc_5_ana_0_ref ) forever loop LCD_Line_1 show( 0, adc_bus_a_pin_0 ) LCD_Write( " " ) show( 1, adc_bus_a_pin_1 ) LCD_Line_2 show( 2, adc_bus_a_pin_2 ) LCD_Write( "," ) show_channel( adc_bus_a_pin_3 ) LCD_Write( " " ) show( 5, adc_bus_a_pin_5 ) delay_100ms end loop