Bascom Codes

9
BASCOM Codes Dim A As Byte , Index As Byte Config Lcdpin = Pin , Db4 = P0.2 , Db5 = P0.3 , Db6 = P0.4 , Db7 = P0.5 , E = P0.6 , Rs = P0.7 Config Lcd = 16 * 2 Begin: Cls Home Upper Lcd "ASSALAMUALAIKUM" 'Text Displayed Lowerline Lcd " WELCOME " 'Text Displayed Wait 3 'Delay for 3 sec Do 'If SW1 pressed If P0.0 = 0 Then 'LED set to be HIGH P2 = 1 Cls Home Upper Lcd "GATE IS OPEN" 'Text Displayed Waitms 50 Lowerline Waitms 15 Lcd "SELAMAT DATANG" For A = 1 To 4 Step 1 'LED move to left bit by bit Shift P2 , Left , 1 Wait 1 Reset P2.0 Shiftlcd Right Waitms 50 Next

description

Bascom Microcontroller Programming

Transcript of Bascom Codes

BASCOM CodesDim A As Byte , Index As Byte

Config Lcdpin = Pin , Db4 = P0.2 , Db5 = P0.3 , Db6 = P0.4 , Db7 = P0.5 , E = P0.6 , Rs = P0.7

Config Lcd = 16 * 2

Begin:

Cls

Home Upper

Lcd "ASSALAMUALAIKUM" 'Text Displayed

Lowerline

Lcd " WELCOME "

'Text Displayed

Wait 3

'Delay for 3 sec

Do

'If SW1 pressed

If P0.0 = 0 Then

'LED set to be HIGH

P2 = 1

Cls

Home Upper

Lcd "GATE IS OPEN"

'Text Displayed

Waitms 50

Lowerline

Waitms 15

Lcd "SELAMAT DATANG"

For A = 1 To 4 Step 1

'LED move to left bit by bit

Shift P2 , Left , 1

Wait 1

Reset P2.0

Shiftlcd Right

Waitms 50

Next

For A = 1 To 4 Step 1

Shift P2 , Left , 1

Wait 1

Reset P2.0

Shiftlcd Left

Waitms 50

Next

P3 = 01

'Motor start do forward (open gate)

Waitms 500

'Delay 500ms

P3 = 00

'Motor stop operate

Goto Begin

'Return to first instruction

End If

If P0.1 = 0 Then

'If SW2 pressed

P2 = 128

Cls

'Text displayed

Home Upper

Lcd "GATE IS CLOSE"

Waitms 50

Lowerline

Waitms 15

Lcd "DATANG LAGI"

For A = 1 To 4 Step 1

'LED move to right bit by bit

Shift P2 , Right , 1

Wait 1

Reset P2.7

Shiftlcd Right

Waitms 50

Next

For A = 1 To 4 Step 1

Shift P2 , Right , 1

Wait 1

Reset P2.7

Shiftlcd Left

Waitms 50

Next

P1 = 0

'7-segment start counting 9-0

For Index = 0 To 9 Step 1

P1 = Lookup(index , 7seg)

Wait 1

Next

P3 = 02

'Motor will do reverse(close gate)

Waitms 500

'Delay for 500ms

P3 = 00

'Motor will stop operates

Goto Begin

'Then its return to first instruction

End If

7seg:

Data 103 , 127 , 7 , 125 , 109 , 102 , 79 , 91 , 6 , 63

Loop

EndProject Operation

INPUT/OUTPUT

Block Diagram

Task DelegationGROUP MEMBER

Mohd Farhan Bin Mohd Shahrin Silva

Fikrul Hakim Bin Othman

Muhammad Khalid Bin Md Taib

WeekPerson In chargeTask

6All team members Project Design

7Fikrul, Farhan and KhalidDesign program

8Fikrul, Khalid, and Farhan1)Test program

2)Design target board

9All membersConstruct and assemble target board

10All membersTest and troubleshoot

11All membersFinal test and complete project

12All membersReport writing

13All membersPresentation

14All membersPresentation

Ghant Chart for Project Operation.

Finally, its return to the first instruction.

Requires us what to do next action.

The motor will do reverse operation since the 7-segment complete the counting to 0.

The gate start to close.

When the operation of LCD and LED done,

The 7-segment will start counting for 10 second

starting at 9 to 0.

Close Gate

SW2 at P0.1 is used to close the gate.

LCD will display the text and move to right.

LED at P2 will high and move to the right bit by bit

When the LCD stop moving and the all LED reset,

The motor at P3 will do forward operation.

The gate open.

Open Gate

Select P0.0 to start operation.

LCD will display the text and move to left.

LED at P2 will high and move to the left bit by bit

-LCD displayed texts.

- The system is ready to be used.

DC Motor

(Open gate/Close gate)

SW1

SW2

LCD Display