One of the assignments we had to do in our Engineering class, was to program circuit, to get the corresponding light to turn on when its corresponding switch is on, and when all four switches are on, a buzzer has to go on to indicate that all four lights are on. This was our project for the end of the year. Here is how I did it!
% Nirose Mohanaruban
% May 9th, 2013 loop %Creation of Variable, and receving input from the breadboard through the parallel port var input := parallelget var output := 0 var s3 := 0 var s4 := 0 var s5 := 0 var s6 := 0 %Converts the inputs to either 0 or 1 s3 := ((input div 8) mod 2) s4 := ((input div 16) mod 2) s5 := ((input div 32) mod 2) s6 := ((input div 64) mod 2) %put "S3 = ", s3, "S4 = ", s4, "S5 = ", s5, "S6 = ", s6 % Conversion of the input values to correspond with D0, D1, D2, D3 output += s3 * 1 % D0 output += s4 * 2 % D1 output += s5 * 4 % D2 output += s6 * 8 % D3 % Makes sure all the switchs are on, and if so, it turns on the buzzer if output = 15 then output := 31 end if % Puts "Output" on screen %put "Output = ", output % The output signal is sent through the parallel port to the breadboard parallelput (output) end loop |