Vous êtes sur la page 1sur 92

CARROT PROJECT BOARD USER MANUAL

Carrot Project Board User Manual

Website: www.magnetcode.com
Email: info@magnetcode.com

Copyright 2017 BizchipTechnology Centre. All Rights Reserved.


Unauthorized duplication or distribution is strictly prohibited.

Bizchip Technology Centre 3363-2, JALA N 18/31, TAMA N SERI SERDA NG, 43300 SERI KEMBANGA N, SELANGOR.

TEL: 012-206 9320 FA X: 03-8948 7451 WEB: http://www.magnetcode.com EMAIL: info@magnetcode.com


Page 1 of 92
CARROT PROJECT BOARD USER MANUAL

Table of Content
Ref. Content Page

1 Install Magnetcode 3

2 Register and login Magnetcode 4

3 Magnetcoe Coding Guide 5

4 Magnetcode Graphic Design 11

5 Startup Project - Welcome 12

6 Project 1- Emergency Light 19

7 Project 2- Digital Door Sign 24

8 Project 3- Digital Clock 29

9 Carrot Project Board Specification 34

10 Carrot Project Board Layout 35

11 Greenbean Microcontroller Specification 39

12 Greenbean Microcontroller Pin Layout 40

13 Project 4 Blinking LED 42

14 Project 5 Remote control LED 48

15 Project 6 Automatic Toilet Light 56

16 Project 7 Visitor Counter 63

17 Project 8 Brightness level meter 70

18 Project 9 Automatic light dimmer 77

19 Project 10 Parking lot vacancy indicator 85

20 Reference 1 - Relay Module Wiring 92

Page 2 of 92
CARROT PROJECT BOARD USER MANUAL

1. Install Magnetcode

Step 1: Install Magnetcode Step 2: Search using Step 3: Press Install button
using Android play store app. 'Magnetcode' keyword. Click to start install Magnetcode.
to install it.

Page 3 of 92
CARROT PROJECT BOARD USER MANUAL

2. Register and login Magnetcode

Step 1: Click the Step 2: If you already have a Step 3: After your account is
Magnetcode account, please created, you will receive a
Magnetcode app icon to key in your username and welcome Email with an
start. password to login. account activation code.
If you do not have an You need to key in the
account, please create one. activation code for first login.

Page 4 of 92
CARROT PROJECT BOARD USER MANUAL

3. Magnetcode Coding Guide

1. For any code involving case detection which starts with 'If' must always
end with 'End If'.

Example 1:

1. ButtonA1_Show = On
2. If ButtonA1 = Pressed
3. Vibrate = On
4. End If
5. Goto = 1

Example 2:

1. Read_Controller
2. If C_Ain1 > 50
3. DOUT1 = On
4. End If
5. Goto = 1

2. We can add multiple tasks under a 'If' condition.

Example 1:

1. ButtonB1_Show = On
2. If ButtonB1 = Pressed
3. LCD_Show = On
4. LCD_Back = Red
5. LCD_Front = Green
6. End If
7. Goto = 1

Example 2:

1. Read_Controller
2. If C_Din1 = 1
3. Vibrate = On
4. LCD_Show = On

Page 5 of 92
CARROT PROJECT BOARD USER MANUAL

5. LCD_Back = Red
6. End If
7. Goto = 1

3. For coding with 'If...End If', you need to add 'Goto' at the end of the code
to keep checking for the condition.

Example 1:

1. ButtonA1_Show = On
2. If ButtonA1 = Pressed
3. Vibrate = On
4. End If
5. Goto = 1

Example 2:

1. Read_Controller
2. If C_DIN1 = 1
3. Vibrate = On
4. End If
5. If C_DIN1 = 0
6. Vibrate = Off
7. End If
8. Goto = 1

4. For coding without 'If...End If', you need to add 'Goto' at the end of the
code if you wish to repeat the same task.

Example 1:

1. Vibrate = On
2. Timer = 2 sec
3. Vibrate = Off
4. Timer = 2 sec
5. Goto = 1

Example 2:

1. DOUT1 = On

Page 6 of 92
CARROT PROJECT BOARD USER MANUAL

2. DOUT2 = Off
3. Timer = 1 sec
4. DOUT1 = Off
5. DOUT2 = On
6. Timer = 1 sec
7. Goto = 1

5. We can add multiple 'Goto' in a code.

Example 1:

1. ButtonA1_Show = On
2. If ButtonA1 = Pressed
3. LCD_Show = On
4. Timer = 1 sec
5. LCD_Show = Off
6. Timer = 1 sec
7. Goto = 3
8. End If
9. Goto = 1

Example 2:

1. LCD_Show = On
2. Value1= Value1 + 1
3. LCD_Show_Var = Value1
4. LCD_Update
5. If Value1 < 5
6. LCD_Back = Green
7. Goto =17
8. End If
9. If Value1 < 10
10. LCD_Back = Pink
11. Goto =17
12. End If
13. If Value1 < 15
14. LCD_Back = Blue
15. Goto =17
16. End If
17. Timer = 1 sec
18. Goto = 1

Page 7 of 92
CARROT PROJECT BOARD USER MANUAL

6. We can add multiple 'If...End If' in a code to perform an 'OR' logic.

Example 1:

1. LCD_Show = On
2. If Value1 < 5
3. LCD_Back = Red
4. End If
5. If Value1 > 5
6. LCD_Back = Green
7. End If
8. Goto = 1

Example 2:

1. Read_Controller
2. If C_Ain1 > 100
3. Vibrate = On
4. LCD_Show = On
5. End If
6. If C_Ain1 < 100
7. Vibrate = On
8. LCD_Show = Off
9. End If
10. Goto = 1

7. We can add multiple 'If' in a 'If...End If' to perform an 'AND' logic.

Example 1:

1. Value1 = 12
2. If Value1 < 30
3. If Value1>10
4. LCD_Show = On
5. End If
6. Goto = 1

Page 8 of 92
CARROT PROJECT BOARD USER MANUAL

Example 2:

1. Read_Controller
2. If C_Din1 = 1
3. If C_Din2 = 1
4. If C_Din3 = 1
5. Vibrate = On
6. End If
7. Goto = 1

8. For coding which related with project board parameters e.g. 'C_Din1',
'C_Din2', 'C_Ain1', you need to add 'Read_Controller' command at the top
of the code.

Example 1:

1. Read_Controller
2. If C_Din1 = 1
3. Vibrate = On
4. End If
5. If C_Din1 = 0
6. Vibrate = Off
7. End If
8. Goto = 1

Example 2:

1. Read_Controller
2. If C_Ain1 < 56
3. Vibrate = On
4. End If
5. If C_Ain3 > 56
6. Vibrate = Off
7. End If
8. Goto = 1

Page 9 of 92
CARROT PROJECT BOARD USER MANUAL

9. We can add '~Note' in our coding to add a comment or a reminder.

Example 1:

1. ~This is my first program


2. LCD_Show = On
3. Timer = 1 sec
4. LCD_Show = Off
5. Timer = 1 sec
6. Goto = 1

Example 2:

1. Read_Controller
2. ~When door is open
3. If C_Din1 = 1
4. LCD_Show = On
5. End If
6. ~When door is close
7. If C_Din1 = 0
8. LCD_Show = Off
9. End If
10. Goto = 1

Page 10 of 92
CARROT PROJECT BOARD USER MANUAL

4. Magnetcode Graphic Design


Graphic design page is important for user interfacing. User can control his / her phone or
project board features through the graphic design page.

User can set title, background, buttons and LCD components in the graphic design page by
using related commands.

Title Background

User can use User can use


command to set title command to set the
text, text color and background color or
background color. background image.

Button
LCD
There are 9 buttons
There is 1 LCD in the in the graphic design
graphic design page. page. The buttons
are arranged in 3
LCD is used to show
rows (1, 2, 3) x 3
system status and
columns (A, B, C).
message.
The buttons are used
to execute the preset
User can use commands.
command to hide or
show it. They can
also set LCD text, User can use
text size, text command to hide or
alignment, show each button.
background color, They can also set
image, text color. text, text size,
background color,
text color for each
button.

Page 11 of 92
CARROT PROJECT BOARD USER MANUAL

5. Startup Project Welcome

In this project we will create a program for Welcome Page that have a
title Welcome with red colour background and a note in a program My
first project.

Youtube Video Link: https://youtu.be/JyPcVG-zhHM

Start

Select commands from


command groups

Edit commands

Rearrange the commands

Run the program

Stop

Page 12 of 92
CARROT PROJECT BOARD USER MANUAL

STEP 1 STEP 2

Home page is used for coding.


In Home page. Please press to
icon: Shift up the current command. open the Add command page. Click

icon: Shift down the current command. any command group name to show all
commands under the command group.
icon: Open the add command page.
icon: Back to Home page.
icon: Main menu with features such as
open, delete, save project... icon: Show all commands under each
command group.
icon: To display the command description.
icon: Hide all commands under each
command group.

icon: Add selected command into the


Home page.

Page 13 of 92
CARROT PROJECT BOARD USER MANUAL

STEP 3 STEP 4

Select any command e.g. After command is added, you can continue
Background_Color = White. to add more commands into the Home
page.
Then click to the command
description. You can press or Smartphones return
Press and hold the selected command or button to close the Add command page.

click to add the selected command to


the Home page.

Page 14 of 92
CARROT PROJECT BOARD USER MANUAL

STEP 5 STEP 6

Click and hold the selected command to


customize it.
Press White and then select color Red as
background color.
Press Run to test the code.
Press the UPDATE button after you
customize the command.

Page 15 of 92
CARROT PROJECT BOARD USER MANUAL

STEP 7 STEP 8

Continue to add more commands into the Continue to add more commands into the
Home page. ~Note = My First Project. Home page , Title_Text = Welcome
.

Then press or Smartphones return


button to close the Add command page. Then press or Smartphones return
button to close the Add command page.

Page 16 of 92
CARROT PROJECT BOARD USER MANUAL

STEP 9 STEP 10

Press Run to test the code. You will


Select any command and press or observe that the LCD screen will display
to arrange the code sequence as follow colour red with title Welcome.
Optionally you can press Save Project to
save the project you created. So that you
can open it in the future.
Done, congratulations.

Page 17 of 92
CARROT PROJECT BOARD USER MANUAL

Expected Output

This is the output for the command Press STOP to end the testing.
Title_Text= Welcome

This is the output for the command


Background_Color= Red.

Page 18 of 92
CARROT PROJECT BOARD USER MANUAL

6. Project 1 - Emergency Light

For project 1, we will change the background colour from red to green every 500
milliseconds.

Youtube Video Link: https://youtu.be/ZoqGg87wR78

Start

Red background

Pause for 500 milliseconds

Green background

Pause for 500 milliseconds

Page 19 of 92
CARROT PROJECT BOARD USER MANUAL

Command Related

Command Command Function


Group
Background_Color=White Graphic Set user interface background with a specific
Design color.
Timer=1 sec Other Pause the program for a specific duration of time.
Goto=1 Other Jump to a specific line.

Page 20 of 92
CARROT PROJECT BOARD USER MANUAL

Program Description
The screen will be in red colour for 500
LINE 1: Background_Color = Red milliseconds.
LINE 2: Timer = 500 msec

LINE 3: Background_Color = Green The screen will be in green colour for 500
milliseconds.
LINE 4: Timer = 500 msec

Jump to line 1 and execute the program again.


LINE 5: Goto=1

Page 21 of 92
CARROT PROJECT BOARD USER MANUAL

Program Operation

The diagram below shows the flow of the Emergency Light program.

LINE 1: Background_Color = Red

LINE 2: Timer = 500 msec

LINE 3: Background_Color = Green

LINE 4: Timer = 500 msec

LINE 5: Goto=1

Page 22 of 92
CARROT PROJECT BOARD USER MANUAL

Exercise 1

Convert the light flasher become a traffic light which can show green for red colour for 3 sec, green
colour 5sec, yellow colour 2sec then repeat.

Youtube Video Link: https://youtu.be/wgA30a28TQw

Answer

Background_Color = Red

Timer = 3 sec

Background_Color = Green

Timer = 5 sec

Background_Color = Yellow

Timer = 2 sec

Goto = 1

Page 23 of 92
CARROT PROJECT BOARD USER MANUAL

7. Project 2 - Digital Door Sign

For project 2, we will program digital door sign Open blinking every 1 second.

Youtube Video Link: https://youtu.be/pI6AIO1xkZM

Page 24 of 92
CARROT PROJECT BOARD USER MANUAL

Command Related

Command Command Function


Group
LCD_Show= On Graphic Show the LCD on the user interface.
Design
LCD_Text_Size= 30 Graphic Set text size on the LCD.
Design
LCD_Align= Middle Graphic Set the alignment of the LCD content.
Design
LCD_Back= Red Graphic Set LCD background with a specific colour.
Design
LCD_Front= Black Graphic Set LCD text with a specific colour.
Design
LCD_Show_Text= Text Graphic Clear and save new text in the memory of LCD.
Design Use # symbol to skip a line.
LCD_Update Graphic Display the memory content of the LCD.
Design
LCD_Clear Graphic Clear text on the LCD.
Design
Timer= 1 sec Other Pause the program for a specific duration of time.

Goto= 1 Other Jump to a specific line.

Page 25 of 92
CARROT PROJECT BOARD USER MANUAL

Program Description

LINE 1: LCD_Show = On
LINE 2: LCD_Text_Size = 80 These commands are to display LCD on
user interface. The LCD have green
LINE 3: LCD_Align = Middle background and white font. It also set
the text size and align the text in the
LINE 4: LCD_Back = Green
middle of the LCD.
LINE 5: LCD_Front = White

LINE 6: LCD_Show_Text = Open


LCD on the user interface will display
LINE 7: LCD_Update Open for 1 second.
LINE 8: Timer = 1 sec

LINE 9: LCD_Clear Nothing will display on the LCD for 1


second.
LINE 10:Timer = 1 sec

Jump to LINE 1 and execute the


LINE 11: Goto = 1 commands again.

Page 26 of 92
CARROT PROJECT BOARD USER MANUAL

Program Operation

The diagram below shows the flow of the Digital Door Sign program.

LINE 1: LCD_Show = On

LINE 2: LCD_Text_Size = 80

LINE 3: LCD_Align = Middle

LINE 4: LCD_Back = Green

LINE 5: LCD_Front = White

LINE 6: LCD_Show_Text = Open

LINE 7: LCD_Update

LINE 8: Timer = 1 sec

LINE 9: LCD_Clear

LINE 10:Timer = 1 sec

LINE 11: Goto = 1

Page 27 of 92
CARROT PROJECT BOARD USER MANUAL

Exercise 2

Upgrade the code to automatic show 'Open' for 10seconds then show 'Close' for 10 seconds.

Youtube Video Link: https://youtu.be/fYcWF7LHsL8

Answer

LCD_Show = On

LCD_Text_Size = 80

LCD_Align = Middle

LCD_Back = Green

LCD_Front = White

LCD_Show_Text = Open

LCD_Update

Timer = 10 sec

LCD_Back = Red

LCD_Show_Text = Close

LCD_Update

Timer = 10 sec

Goto = 1

Page 28 of 92
CARROT PROJECT BOARD USER MANUAL

8. Project 3 Digital Clock

For project 3, we will create a digital clock that will display time on the LCD.

Youtube Video Link: https://youtu.be/_gepMnMHqCY

Start

Display time on LCD

Pause for 1 second

Page 29 of 92
CARROT PROJECT BOARD USER MANUAL

Command Related

Command Command Function


Group
LCD_Show= On Graphic Show the LCD on the user interface.
Design
LCD_Align= Middle Graphic Set the alignment of the LCD content.
Design
LCD_Show_Text= Text Graphic Clear and save new text in the memory of LCD.
Design Use # symbol to skip a line.
LCD_Add_Var=Text Graphic Add a variable in the memory of LCD.
Design
LCD_Update Graphic Display the memory content of the LCD.
Design
Timer= 1 sec Other Pause the program for a specific duration of time.

Goto= 1 Other Jump to a specific line.

Page 30 of 92
CARROT PROJECT BOARD USER MANUAL

Program Description

LINE 1: LCD_Show = On These commands are to display


LCD on user interface. It also align
LINE 2: LCD_Align = Middle the text in the middle of the LCD.

LINE 3: LCD_Show_Text = Time now:#


These commands will make the
LINE 4: LCD_Add_Var = Time
LCD display the current time for 1
LINE 5: LCD_Update second.

LINE 6: Timer = 1 sec

Jump to line 1 and execute the


LINE 7: Goto = 1 commands again.

Page 31 of 92
CARROT PROJECT BOARD USER MANUAL

Program Operation

The diagram below shows the flow of the Digital Clock program.

LINE 1: LCD_Show = On

LINE 2: LCD_Align = Middle

LINE 3: LCD_Show_Text = Time now:#

LINE 4: LCD_Add_Var = Time

LINE 5: LCD_Update

LINE 6: Timer = 1 sec

LINE 7: Goto = 1

Page 32 of 92
CARROT PROJECT BOARD USER MANUAL

Exercise 3

Upgrade the code to show time and date on the LCD

Youtube Video Link: https://youtu.be/77WSmFIWUhM

Answer

LCD_Show = On

LCD_Align = Middle

LCD_Show_Text = Time now:#

LCD_Add_Var = Time

LCD_Add_Text = #Date today:#

LCD_Add_Var = Date

LCD_Update

Timer = 1 sec

Goto = 1

Page 33 of 92
CARROT PROJECT BOARD USER MANUAL

9. Carrot Project Board Specification

Power Supply: 12VDC (Power Adapter, 8AA battery, Lead Acid Battery)
Operating Frequency: 20MHz
Bluetooth Data Speed: 9600bps, TTL*
Total I/O Pins: 19
Analog Input: 5
Digital Input: 4
Digital Output: 6
Pulse Output: 2
Servo Motor Output: 2
Analog Input Voltage Range: 0VDC to 5VDC.
Digital Input Voltage: 0VDV (logic 0) or 5VDC (logic 1).
Digital Output Voltage: Off = 0VDC (logic 0), On = 5VDC (logic 1).
Pulse Output Duty Ratio Range: 0% to 100%, TTL*
Servo Motor Output: 40Hz, TTL*
Servo Motor Pulse Width Range: 0.5ms (servo will rotate to 0 degree) to
2.5ms (servo will rotate to 180 degree).

* Note: TTL voltage level uses 0V for logic 0 and uses 5V for logic 1.

Page 34 of 92
CARROT PROJECT BOARD USER MANUAL

10. Carrot Project Board Layout

Page 35 of 92
CARROT PROJECT BOARD USER MANUAL

Item Function

Greenbean Greenbean is the Microcontroller for the Carrot project board.


Microcontroller

POWER1, POWER2 DC power supply for the project board. Support DC voltage from
9V to 18V. E.g. 8AA batteries, 12VDC lead acid battery, 12VDC
power adapter.

POWER3 DC power supply for servo motor 1 and servo motor 2. Servo
motor 1 and servo motor 2 support DC voltage from 4.5V (3AA
batteries) to 6V (4AA batteries).

ONOFF1 On off carrot project board through a sliding switch.

ONOFF2 On off carrot project through an external switch.

* The external switch is useful when the carrot project board


is inside a casing.

ONOFF3 On off servo motor 1 and servo motor2 through an external switch.

PL1 Power on off indicator for the carrot project board.

PL2 External power on off indicator for the carrot project board.

* The optional power on off indicator is useful when the carrot


project board is inside a casing.

PL3 Power on off indicator for servo motor 1 and servo motor 2.

PL4 External power on off indicator for servo motor 1 and servo mo tor
2.

* The optional power on off indicator is useful when the carrot


project board is inside a casing.

Digital Output DOUT1, 2, 3, 4, 5 and 6 are digital outputs of the project board.

(DOUT1, DOUT2, When DOUT1, 2, 3, 4, 5 or 6 is turned on, it will provide a 5VDC


DOUT3, DOUT4, output (logic 1) with a maximum of 20mA current to the connected
DOUT5, DOUT6) device.

Page 36 of 92
CARROT PROJECT BOARD USER MANUAL

When DOUT1, 2, 3, 4, 5 or 6 is turned off, it will provide a 0VDC


output (logic 0) with a 0mA current to the connected device.

Digital Input DIN1, DIN2, DIN3 and DIN4 are digital inputs of the project board.

(DIN1, DIN2,DIN3, You can connect it to any digital sensor or switch e.g. push button,
DIN4) float switch, obstacle sensor.

Digital input only accepts 0VDC and 5VDC. Any voltage below
0VDC or above 5VDC will damage the Microcontroller. Any voltage
between 0VDC to 5VDC is invalid.

When any digital input pin detected a 5VDC input. It will output
logic 1 (C_Din=1). When any digital input pin detected a 0VDC
input. It will output logic 0 (C_Din=0).

* Note: All the digital input pins on the Carrot project board
are enhanced with a 10KR pulled down resistor. Therefore,
you can connect switches or buttons to DIN1, DIN2, DIN3 and
DIN4 without additional circuitry.

Analog Input AIN1, AIN2, AIN3, AIN4, AIN5 are the analog inputs of the project
board.
(AIN1, AIN2, AIN3,
AIN4, AIN5) Analog input accepts any voltage from 0VDC to 5VDC. Any
voltage below 0VDC or above 5VDC will burn the Microcontroller.

You can connect it to any analog sensor with an output voltage


from 0VDC to 5VDC. The analog voltage value will be converted to
digital values through a 8 bit analog to digital converter (ADC)
module in the Greenbean Microcontroller.

The ADC value will vary from 0 to 255 when detected voltage
changes from 0VDC to 5VDC.

Pulse Output PULSE1 and PULSE2 are pulse output of the project board. The
voltage of the pulse is 5VDC. Both pulse outputs can vary from a
(Pulse 1, PULSE2)
duty ratio of 0% (no output) to 100% (strongest output).

Page 37 of 92
CARROT PROJECT BOARD USER MANUAL

Servo Motor Output SERVO1, SERVO2 are servo motor outputs of the project board.
Each servo motor output can control a servo motor to rotate from 0
(Servo 1, 2)
to 180 degree (depending on the characteristic of the servo motor).

Connect GND pin to GND (-ve) pin of the servo motor.

Connect POUT2 pin to VCC (+ve) pin of the servo motor.

Connect SIG pin to signal pin of the servo motor.

Bluetooth Module Bluetooth module is used to link the Carrot project board to the
Smartphone or tablet. Each Bluetooth module has an unique ID for
Bluetooth pairing purpose.

* Note: The PIN (or password) for Bluetooth pairing is: 1234

Page 38 of 92
CARROT PROJECT BOARD USER MANUAL

11. Greenbean Microcontroller Specification

Green bean is the main controller of the


Packaging: DIP
Total Pins: 28
Total I/O Pins: 19
Power Supply: 5VDC
Operating Frequency: 20MHz
Bluetooth Data Speed: 9600bps, TTL*
Maximum current output for each digital output: 20mA
Maximum current output for Carrot Microcontroller: 100mA
Analog Input: 5
Digital Input: 4
Digital Output: 6
Pulse Output: 2
Servo Motor Output: 2
Analog Input Voltage Range: 0VDC to 5VDC.
Digital Input Voltage: 0VDV (logic 0) or 5VDC (logic 1).
Digital Output Voltage: Off = 0VDC (logic 0), On = 5VDC (logic 1).
Pulse Output Duty Ratio Range: 0% to 100%, TTL*
Servo Motor Output: 40Hz, TTL*
Servo Motor Pulse Width Range: 0.5ms (servo will rotate to 0 degree) to
2.5ms (servo will rotate to 180 degree).

* Note:

1. TTL voltage level uses 0V for logic 0 and uses 5V for logic 1.

2. Microcontroller will automatic reset if over current case is detected.

Page 39 of 92
CARROT PROJECT BOARD USER MANUAL

12. Greenbean Microcontroller Pin Layout

Pin Feature

This pin is connected to 5VDC when the Greenbean controller is


operating.
Reset
When this pin is connected to ground (0VDC). The Greenbean controller
will reset.

VDD VDD is the power supply pin of the Greenbean controller. Connect it to
the 5VDC of the power source.

VSS VSS is the common ground pin of the Greenbean controller. Connect it
to 0VDC of the power source.

AIN1, AIN2, AIN3, AIN1, AIN2, AIN3 and AIN4 are the analog inputs of the project board.
AIN4. AIN5
You can connect it to any analog sensor with an output voltage from
0VDC to 5VDC. The analog voltage value will be converted to digital
values through a 8 bit ADC (analog to digital converter) module in the
Greenbean controller.

DOUT1, DOUT2, DOUT1, 2, 3, 4, 5 and 6 are digital outputs of the project board.
DOUT3, DOUT4,
When DOUT1, 2, 3, 4, 5 or 6 is turned on, it will provide a 5VDC output

Page 40 of 92
CARROT PROJECT BOARD USER MANUAL

DOUT5, DOUT6 with a maximum of 20mA current to the connected device.

When DOUT1, 2, 3, 4, 5 or 6 is turned off, it will provide a 0VDC output


with a 0mA current to the connected device.

PULSE1, PULSE1 and PULSE2 are pulse output of the project board. The
PULSE2 voltage of the pulse is 5VDC. Both pulse outputs can vary from a duty
ratio of 0% (no output) to 100% (strongest output).

DIN1, DIN2, DIN1, DIN2, DIN3 and DIN4 are digital inputs of the project board.
DIN3, DIN4 Digital input only accepts 0VDC and 5VDC. Any voltage below 0VDC or
above 5VDC will burn the Microcontroller. Any voltage between 0VDC to
5VDC is invalid.

When any digital input pin detected a 5VDC input. It will output logic 1.
When any digital input pin detected a 0VDC input. It will output logic 0.

SERVO1, SERVO1, SERVO2 are servo motor outputs of the project board. Each
SERVO2 servo motor output can control a servo motor to rotate from 0 to 180
degree (depending on the characteristic of the servo motor).

TX RS232 serial data output pin of the Greenbean controller. This pin is
used to send data to the Smartphone or tablet.

RX RS232 serial data input pin of the Greenbean controller. This pin is
used to receive data from the Smartphone or tablet.

CLOCK_1, These 2 pins are clock input for the Greenbean controller. Connect
CLOCK_2 these 2 pins to a 20MHz oscillator (crytal). The clock pulses from the
oscillator can be used to execute commands in the Greenbean
controller.

Page 41 of 92
CARROT PROJECT BOARD USER MANUAL

13. Project 4 Blinking LED

Turn on red color LED (at Dout1) for 1 sec, then turn off red color LED for 1 sec.

Youtube Video Link- https://youtu.be/jbL4Yl4flY0

Start

Red LED on

Pause for 1 second

Red LED off

Pause for 1 second

Page 42 of 92
CARROT PROJECT BOARD USER MANUAL

Command Related

Command Command Function


Group
Dout1= On Controller Turn on or off DOUT output on the project
I/O board
Timer=1 sec Other Pause the program for a specific duration of
time.
Goto=1 Other Jump to a specific line.

Wiring

DOUT1 +

GND -

Page 43 of 92
CARROT PROJECT BOARD USER MANUAL

Program Description

LINE 1: Dout1 = On
To turn on red colour LED for 1 second.
LINE 2: Timer = 1 sec

LINE 3: Dout1 = Off


To turn on red colour LED for 1 second.
LINE 4: Timer = 1 sec

LINE 5: Goto = 1 Jump to LINE 1 and execute the program again.

Page 44 of 92
CARROT PROJECT BOARD USER MANUAL

Program Operation

The diagram below shows the flow of the program when it runs.

LINE 1: Dout1 = On

LINE 2: Timer = 1 sec

LINE 3: Dout1 = Off

LINE 4: Timer = 1 sec

LINE 5: Goto = 1

Page 45 of 92
CARROT PROJECT BOARD USER MANUAL

Exercise 4

Design a traffic light with following sequence:

Turn on Red colour LED (at Dout1) for 3 sec,

Then turn on Green colour LED (at Dout2) for 3 sec,

Then turn on Yellow colour LED (at Dout3) for 1 sec.

Youtube Video Link: https://youtu.be/CpNXEL65XV0

Wiring

DOUT2 +

GND -

DOUT3 +

GND -

Page 46 of 92
CARROT PROJECT BOARD USER MANUAL

Answer

Dout1 = On

Timer = 3 sec
Dout1 = Off

Dout2 = On

Timer = 3 sec

Dout2 = Off

Dout3 = On

Timer = 1 sec

Dout3 = Off

Goto = 1

Page 47 of 92
CARROT PROJECT BOARD USER MANUAL

14. Project 5 Remote control LED

Turn on white color LED (at Dout1) when button A1 is pressed.

Turn off white color LED (at Dout1) when button B1 is pressed.

Youtube Video Link: https://youtu.be/sEl9sgoWJZQ

Start

Yes White On button is


White LED on pressed?

No

Yes White Off button is


White LED off pressed?

No

Page 48 of 92
CARROT PROJECT BOARD USER MANUAL

Command Related

Command Command Function


Group
Dout1= On Controller I/O Turn on or off DOUT output on the
project board
Timer=1 sec Other Pause the program for a specific duration
of time.
Goto=1 Other Jump to a specific line.
ButtonA1_Show = On Graphic Design Show a specific button on the user
interface.
ButtonA1_Show_Text = Graphic Design Clear and save new text in the memory
Text
ButtonA1_Update Graphic Design Display the memory content of a specific
button.
If ButtonA1 = Pressed Decision If a specific button is pressed.
ButtonA1_Show = On Graphic Design Show a specific button on the user
interface.
ButtonA1_Show_Text = Graphic Design Clear and save new text in the memory
Text

Wiring

Page 49 of 92
CARROT PROJECT BOARD USER MANUAL

Program Description

LINE 1: ButtonA1_Show = On
To display White On button for user to
LINE 2: ButtonA1_Show_Text = White On press.
LINE 3: ButtonA1_Update

LINE 4: If ButtonA1 = Pressed


If White On is pressed, white LED will
LINE 5: Dout1 = On
turn on.
LINE 6: End If

LINE 7: ButtonB1_Show = On
To display White Off button for user to
LINE 8: ButtonB1_Show_Text = White Off press.
LINE 9: ButtonB1_Update

LINE 10: If ButtonB1 = Pressed


If White Off is pressed, white LED will
LINE 11: Dout1 = Off turn off.
LINE 12: End If

Jump to LINE 1 and execute the


LINE 13: Goto = 1 command again.

Page 50 of 92
CARROT PROJECT BOARD USER MANUAL

Program Operation

The diagram below shows the flow of the program when no button is pressed.

LINE 1: ButtonA1_Show = On

LINE 2: ButtonA1_Show_Text = White On

LINE 3: ButtonA1_Update

LINE 4: If ButtonA1 = Pressed

LINE 5: Dout1 = On

LINE 6: End If

LINE 7: ButtonB1_Show = On

LINE 8: ButtonB1_Show_Text = White Off

LINE 9: ButtonB1_Update

LINE 10: If ButtonB1 = Pressed

LINE 11: Dout1 = Off

LINE 12: End If

LINE 13: Goto = 1

Page 51 of 92
CARROT PROJECT BOARD USER MANUAL

The diagram below shows the flow of the program when button White On is pressed.

LINE 1: ButtonA1_Show = On

LINE 2: ButtonA1_Show_Text = White On

LINE 3: ButtonA1_Update

LINE 4: If ButtonA1 = Pressed

LINE 5: Dout1 = On

LINE 6: End If

LINE 7: ButtonB1_Show = On

LINE 8: ButtonB1_Show_Text = White Off

LINE 9: ButtonB1_Update

LINE 10: If ButtonB1 = Pressed

LINE 11: Dout1 = Off

LINE 12: End If

LINE 13: Goto = 1

Page 52 of 92
CARROT PROJECT BOARD USER MANUAL

The diagram below shows the flow of the program when button White Off is pressed.

LINE 1: ButtonA1_Show = On

LINE 2: ButtonA1_Show_Text = White On

LINE 3: ButtonA1_Update

LINE 4: If ButtonA1 = Pressed

LINE 5: Dout1 = On

LINE 6: End If

LINE 7: ButtonB1_Show = On

LINE 8: ButtonB1_Show_Text = White Off

LINE 9: ButtonB1_Update

LINE 10: If ButtonB1 = Pressed

LINE 11: Dout1 = Off

LINE 12: End If

LINE 13: Goto = 1

Want to upgrade your project with real 12V LED lamp?


Refer page 92: Relay Module Wiring

Page 53 of 92
CARROT PROJECT BOARD USER MANUAL

Exercise 5
Upgrade the project with a red colour LED (at Dout2). Turn on red colour LED (at Dout2) when
button A2 is pressed. Turn off red colour LED (at Dou2) when button B2 is pressed.

Youtube Video Link: https://youtu.be/SX3H4LXEVhA

Wiring

Page 54 of 92
CARROT PROJECT BOARD USER MANUAL

Answer
ButtonA1_Show = On

ButtonA1_Show_Text = White On

ButtonA1_Update

If ButtonA1 = Pressed

Dout1 = On

End If

ButtonB1_Show = On

ButtonB1_Show_Text = White Off

ButtonB1_Update

If ButtonB1 = Pressed

Dout1 = Off

End If

ButtonA2_Show = On

ButtonA2_Show_Text = Red On

ButtonA2_Update

If ButtonA2 = Pressed

Dout2 = On

End If

ButtonB2_Show = On

ButtonB2_Show_Text = Red Off

ButtonB2_Update

If ButtonB2 = Pressed

Dout2 = Off

End If

Goto = 1

Page 55 of 92
CARROT PROJECT BOARD USER MANUAL

15. Project 6 Automatic Toilet Light

Turn on white LED (at Dout1) when door sensor (at Din1) is detected closed.

Youtube Video Link: https://youtu.be/VR1hImgv2Rw

Start

Yes
Door is closed?
White LED on

No

Yes
White LED off Door is open?

No

Page 56 of 92
CARROT PROJECT BOARD USER MANUAL

Command Related

Command Command Function


Group
Dout1= On Controller I/O Turn on or off DOUT output on the project board
Timer=1 sec Other Pause the program for a specific duration of time.

Goto=1 Other Jump to a specific line.

Read_Controller Controller I/O Read all sensors values from the project board.
If C_Din1= 1 Decision If a specific d igital sensor value on the project
board matches with a specific condition
End If Decision Terminate any if co mmand.

Wiring

DIN1

5V

Page 57 of 92
CARROT PROJECT BOARD USER MANUAL

Program Description
To read all the sensors values in the
LINE 1: Read_Controller controller.

LINE 2: If C_Din1 = 1
If door is closed, white LED will turn on.
LINE 3: Dout1 = On

LINE 4: End If

LINE 5: If C_Din1 = 0
If door is open, white LED will turn off
LINE 6: Dout1 = Off

LINE 7: End If

Jump to LINE 1 and execute program


LINE 8: Goto = 1 again.

Page 58 of 92
CARROT PROJECT BOARD USER MANUAL

Program Operation

The diagram below shows the flow of the program when the door is open.

LINE 1: Read_Controller

LINE 2: If C_Din1 = 1

LINE 3: Dout1 = On

LINE 4: End If

LINE 5: If C_Din1 = 0

LINE 6: Dout1 = Off

LINE 7: End If

LINE 8: Goto = 1

Page 59 of 92
CARROT PROJECT BOARD USER MANUAL

The diagram below shows the flow of the program when the door is closed.

LINE 1: Read_Controller

LINE 2: If C_Din1 = 1

LINE 3: Dout1 = On

LINE 4: End If

LINE 5: If C_Din1 = 0

LINE 6: Dout1 = Off

LINE 7: End If

LINE 8: Goto = 1

Want to upgrade your project with real 12V LED lamp?


Refer page 92: Relay Module Wiring

Page 60 of 92
CARROT PROJECT BOARD USER MANUAL

Exercise 6
Upgrade the project to turn on white LED (at Dout1) and red LED (at Dout2) when door sensor (at
Din1) is close. Turn on green LED (at Dout3) when door is open.

Youtube Video Link: https://youtu.be/ixDehFdYzFA

Wiring

DOUT2 +

GND -

DOUT3 +

GND -

Page 61 of 92
CARROT PROJECT BOARD USER MANUAL

Answer
Read_Controller

If C_Din1 = 1

Dout1 = On

Dout2 = On

Dout3 = Off

End If

If C_Din1 = 0

Dout1 = Off

Dout2 = Off

Dout3 = On

End If

Goto = 1

Page 62 of 92
CARROT PROJECT BOARD USER MANUAL

16. Project 7 Visitor Counter

Design a visitor counter to increase counter value with 1 when door sensor (at Din1)
is open and closed.

Youtube Video Link: https://youtu.be/HFItwQ9_1Ac

Start

Yes
Door is open and
Counter increase by 1 closed?

No

Page 63 of 92
CARROT PROJECT BOARD USER MANUAL

Command Related

Command Command Function


Group
Dout1= On Controller I/O Turn on or off DOUT output on the
project board
Timer=1 sec Other Pause the program for a specific duration
of time.
Goto=1 Other Jump to a specific line.

LCD_Show_Var= Time Graphic Design Clear and display a new variable on the
LCD.
LCD_Update Graphic Design Display the memory content of the LCD.

If C_Din1= 1 Decision If a specific digital sensor value on the


project board matches with a specific
condition
End If Decision Terminate any if command.

Value1= Value2+1 Variable Set the first variable value with


calculation result of the second variable
value and an integer.
If Value1=1 Decision If the variable matches with a specific
integer condition.
Value1= 0 Variable Set variable value with an integer.

Read_Controller Controller I/O Read all sensors values from the project
board.

Wiring

5V

DIN1

Page 64 of 92
CARROT PROJECT BOARD USER MANUAL

Program Description

LINE 1: Value1 = 0 To set value 0 to value1 and value2


LINE 2: Value2 = 0

LINE 3: LCD_Show = On To display LCD on user interface.

To read all the sensors values in the


LINE 4: Read_Controller controller.

LINE 5: If C_Din1 = 0 The condition is if the door is open and if


value1 is equal to 1.
LINE 6: If Value1 = 1

LINE 7: Value2 = Value2 + 1


The counter will start count, add by 1
LINE 8: LCD_Show_Var = Value2 and LCD will display the current counter.
LINE 9: LCD_Update

LINE 10: Value1 = 0 The counter will stop counting.


LINE 11: End If

LINE 12: If C_Din1 = 1


If the door is closed, the counter will add
LINE 13: Value1 = 1 by 1.
LINE 14: End If

Jump to LINE 4 and execute the program


LINE 15: Goto = 4 again.

Page 65 of 92
CARROT PROJECT BOARD USER MANUAL

Program Operation

The diagram below shows the flow of the program when Door is open

LINE 1: Value1 = 0

LINE 2: Value2 = 0

LINE 3: LCD_Show = On

LINE 4: Read_Controller

LINE 5: If C_Din1 = 0

LINE 6: If Value1 = 1

LINE 7: Value2 = Value2 + 1

LINE 8: LCD_Show_Var = Value2

LINE 9: LCD_Update

LINE 10: Value1 = 0

LINE 11: End If

LINE 12: If C_Din1 = 1

LINE 13: Value1 = 1

LINE 14: End If

LINE 15: Goto = 4

Page 66 of 92
CARROT PROJECT BOARD USER MANUAL

The diagram below shows the flow of the program when Door is closed.

LINE 1: Value1 = 0

LINE 2: Value2 = 0

LINE 3: LCD_Show = On

LINE 4: Read_Controller

LINE 5: If C_Din1 = 0

LINE 6: If Value1 = 1

LINE 7: Value2 = Value2 + 1

LINE 8: LCD_Show_Var = Value2

LINE 9: LCD_Update

LINE 10: Value1 = 0

LINE 11: End If

LINE 12: If C_Din1 = 1

LINE 13: Value1 = 1

LINE 14: End If

LINE 15: Goto = 4

Page 67 of 92
CARROT PROJECT BOARD USER MANUAL

Exercise 7
Upgrade the project with a reset button (at Din2).

When reset button is pressed. Reset counter value.

Youtube Video Link: https://youtu.be/raJqMIQ6aXY

Wiring

5V
DIN2

5V

Page 68 of 92
CARROT PROJECT BOARD USER MANUAL

Answer
Value1 = 0

Value2 = 0

LCD_Show = On

Read_Controller

If C_Din1 = 0

If Value1 = 1

Value2 = Value2 + 1

LCD_Show_Var = Value2

LCD_Update

Value1 = 0

End If

If C_Din1 = 1

Value1 = 1

End If

If C_Din2 = 1

Value2 = 0

End If

Goto = 4

Page 69 of 92
CARROT PROJECT BOARD USER MANUAL

17. Project 8 Brightness level meter

Design a brightness level meter which can display the brightness level sensor's
value (light dependent resistor) (at pin Ain1) on the LCD. When the sensor's value is
<=127, change LCD to green color. When the sensor's value is >127, change LCD to
red color.

Youtube Video Link:https://www.youtube.com/watch?v=op6QkLG-mHY

Start

Display current
brightness level

Yes
LCD background turn Brightness level
green lower than 127?

No

Yes Brightness level


LCD background turn red higher than 127?

No

Page 70 of 92
CARROT PROJECT BOARD USER MANUAL

Command Related

Command Command Function


Group
LCD_Show= On Graphic Show the LCD on the user interface
Design
Read_Controller Controller Read all sensors values from the project
I/O board
LCD_Text_Size= 30 Graphic Set text size on the LCD
Design
LCD_Show_Var= Time Graphic Clear and save new variable in the memory of
Design LCD.
If C_Ain=0 Decision If a specific analog sensor value on the project
board matches with a specific condition
LCD_Back= Red Graphic Set LCD background with a specific colour
Design
End If Decision Terminate any if command
LCD_ Update Graphic Display the memory content of the LCD
Design
Goto=1 Other Jump to a specific line.

Wiring

5V
AIN1

GND

Page 71 of 92
CARROT PROJECT BOARD USER MANUAL

Program Description

To display LCD on user interface.


LINE 1: LCD_Show = On

To read the brightness level sensor (light


LINE 2: Read_Controller dependent resistor) value.

LINE 3: LCD_Text_Size = 70 To set the font size on the LCD to 70. LCD
LINE 4: LCD_Show_Var = C_Ain1 will display current brightness level.

LINE 5: If C_Ain1 <= 127


If the brightness level is lower than 127,
LINE 6: LCD_Back = Green background of LCD will turn Green.
LINE 7: End If

LINE 8: If C_Ain1 > 127


If the brightness level is higher than 127,
LINE 9: LCD_Back = Red background of LCD will turn Red.
LINE 10: End If

To display current brightness level on LCD.


LINE 11: LCD_Update

Jump to LINE 1 and execute the program


LINE 12: Goto = 1 again.

Page 72 of 92
CARROT PROJECT BOARD USER MANUAL

Program Operation

The diagram below shows the flow of the program when the brightness level is lower than 127.

LINE 1: LCD_Show = On

LINE 2: Read_Controller
LINE 3: LCD_Text_Size = 70

LINE 4: LCD_Show_Var = C_Ain1

LINE 5: If C_Ain1 <= 127


LINE 6: LCD_Back = Green

LINE 7: End If

LINE 8: If C_Ain1 > 127

LINE 9: LCD_Back = Red


LINE 10: End If

LINE 11: LCD_Update

LINE 12: Goto = 1

Page 73 of 92
CARROT PROJECT BOARD USER MANUAL

The diagram below shows the flow of the program when the brightness level is higher than 127.

LINE 1: LCD_Show = On

LINE 2: Read_Controller

LINE 3: LCD_Text_Size = 70
LINE 4: LCD_Show_Var = C_Ain1

LINE 5: If C_Ain1 <= 127

LINE 6: LCD_Back = Green

LINE 7: End If
LINE 8: If C_Ain1 > 127

LINE 9: LCD_Back = Red

LINE 10: End If

LINE 11: LCD_Update


LINE 12: Goto = 1

Page 74 of 92
CARROT PROJECT BOARD USER MANUAL

Exercise 8

Upgrade the brightness level meter to:


Turn off LED (at pin Dout1) when sensor's value < 127.

Blink LED (at pin Dout1) when sensor's value >=127.

Youtube Video Link: https://youtu.be/xFg5yBoF82c

Wiring

DOUT1 +
GND -

Page 75 of 92
CARROT PROJECT BOARD USER MANUAL

Answer

LCD_Show = On

Read_Controller
LCD_Text_Size = 70

LCD_Show_Var = C_Ain1

If C_Ain1 <= 127

LCD_Back = Green

Dout1 = Off

End If

If C_Ain1 > 127

LCD_Back = Red

Dout1 = On

Timer = 500 msec

Dout1 = Off

Timer = 500 msec

End If

LCD_Update

Goto = 1

Want to upgrade your project with real 12V LED lamp?


Refer page 92: Relay Module Wiring

Page 76 of 92
CARROT PROJECT BOARD USER MANUAL

18. Project 9 Automatic light dimmer

Design an automatic light dimmer which can detect environment brightness using
brightness level sensor's (light dependent resistor) (at pin Ain1). When the sensor's
value is <160, change LCD to blue color and turn off white LED (at Pulse1). When
the sensor's value is >=160 and <200, change LCD to orange color and control white
LED (at Pulse1) with 5% brightness. When the sensor's value is >=200, change LCD
to red color and control white LED (at Pulse1) with 100% brightness.

Youtube Video Link: https://youtu.be/WuPf9DWjECw

Start

LCD background turn Yes


Brightness level
green and white LED lower than 127?
turn off

No

LCD background turn Yes Brightness level


orange and white LED higher than 127?
turn on at 5% bright

No

LCD background turn red Yes Brightness level


and white LED turn on at higher than 127?
100% bright

No

Page 77 of 92
CARROT PROJECT BOARD USER MANUAL

Command Related

Command Command Function


Group
LCD_Show= On Graphic Show the LCD on the user interface
Design
Read_Controller Controller Read all sensors values from the project
I/O board
LCD_Text_Size= 30 Graphic Set text size on the LCD
Design
If C_Ain=0 Decision If a specific analog sensor value on the project
board matches with a specific condition
LCD_Back= Red Graphic Set LCD background with a specific colour
Design
End If Decision Terminate any if command
LCD_ Update Graphic Display the memory content of the LCD
Design
Pulse1=0 Controller Control output strength of the pulse output
I/O on the project board
Goto=1 Other Jump to a specific line.

Wiring

PULSE1 +

GND -

Page 78 of 92
CARROT PROJECT BOARD USER MANUAL

Program Description

To display LCD on user interface.


LINE 1: LCD_Show = On

LINE 2: Read_Controller To read the brightness level sensor (light


dependent resistor) value.

LINE 3: If C_Ain1 < 160


If brightness level is lower than 160,
LINE 4: LCD_Back = Blue background of LCD will turn Blue and
LINE 5: Pulse1 = 0 white LED will turn off.

LINE 6: End If

LINE 7: If C_Ain1 >= 160

LINE 8: If C_Ain1 <200 If brightness level is between of 160 to


LINE 9: LCD_Back = Orange 200 background of LCD will turn Orange
and white LED will turn on at 5% bright.
LINE 10: Pulse1 = 5

LINE 11: End If

LINE 12: If C_Ain1 >= 200


LINE 13: LCD_Back = Red If brightness level is higher than 200
background of LCD will turn Red and white
LINE 14: Pulse1 = 100
LED will turn on at 100% bright.
LINE 15: End If

Jump to LINE 1 and execute the program


LINE 16: Goto = 1 again.

Page 79 of 92
CARROT PROJECT BOARD USER MANUAL

Program Operation

The diagram below shows the flow of the program when the brightness level is lower than 160.

LINE 1: LCD_Show = On

LINE 2: Read_Controller

LINE 3: If C_Ain1 < 160

LINE 4: LCD_Back = Blue


LINE 5: Pulse1 = 0
LINE 6: End If

LINE 7: If C_Ain1 >= 160

LINE 8: If C_Ain1 <200


LINE 9: LCD_Back = Orange

LINE 10: Pulse1 = 5

LINE 11: End If

LINE 12: If C_Ain1 >= 200


LINE 13: LCD_Back = Red

LINE 14: Pulse1 = 100

LINE 15: End If

LINE 16: Goto = 1

Page 80 of 92
CARROT PROJECT BOARD USER MANUAL

The diagram below shows the flow of the program when the brightness level is between of 160 to
200.

LINE 1: LCD_Show = On
LINE 2: Read_Controller

LINE 3: If C_Ain1 < 160

LINE 4: LCD_Back = Blue

LINE 5: Pulse1 = 0
LINE 6: End If

LINE 7: If C_Ain1 >= 160

LINE 8: If C_Ain1 <200

LINE 9: LCD_Back = Orange


LINE 10: Pulse1 = 5

LINE 11: End If

LINE 12: If C_Ain1 >= 200


LINE 13: LCD_Back = Red

LINE 14: Pulse1 = 100

LINE 15: End If

LINE 16: Goto = 1

Page 81 of 92
CARROT PROJECT BOARD USER MANUAL

The diagram below shows the flow of the program when the brightness level is higher than 200.

LINE 1: LCD_Show = On

LINE 2: Read_Controller
LINE 3: If C_Ain1 < 160

LINE 4: LCD_Back = Blue

LINE 5: Pulse1 = 0

LINE 6: End If
LINE 7: If C_Ain1 >= 160

LINE 8: If C_Ain1 <200

LINE 9: LCD_Back = Orange

LINE 10: Pulse1 = 5


LINE 11: End If

LINE 12: If C_Ain1 >= 200

LINE 13: LCD_Back = Red

LINE 14: Pulse1 = 100


LINE 15: End If

LINE 16: Goto = 1

Page 82 of 92
CARROT PROJECT BOARD USER MANUAL

Exercise 9

Upgrade the light dimmer to:


Display 'Bright' on the LCD when brightness sensor's value is <160

Display 'Dim' on the LCD when brightness sensor's value is >=160 and <200

Display 'Dark' on the LCD when brightness sensor's value is >=200


Youtube Video Link: https://youtu.be/YGTHm9LRUFU

Wiring

Page 83 of 92
CARROT PROJECT BOARD USER MANUAL

Answer

LCD_Show = On

Read_Controller
If C_Ain1 < 160

LCD_Show_Text = Bright

LCD_Back = Blue

Pulse1 = 0

End If

If C_Ain1 >= 160

If C_Ain1 <200

LCD_Show_Text = Dim

LCD_Back = Orange

Pulse1 = 5

End If

If C_Ain1 >= 200

LCD_Show_Text = Dark

LCD_Back = Red

Pulse1 = 100

End If

LCD_Update

Goto = 1

Page 84 of 92
CARROT PROJECT BOARD USER MANUAL

19. Project 10 Parking lot vacancy indicator

Design a parking lot vacancy detector which can use brightness sensor (at Ain1) to
detect car:

The system will display 'Lot 1: Occupied' on the LCD and turn on LED (at Dout1)
when lot 1 is occupied.

The system will display 'Lot 1: Empty' on the LCD and turn off LED (at Dout1) when
lot 1 is not occupied.

Youtube Video Link: https://youtu.be/vxeDnhGfM5I

Start

Yes
LCD display Lot 1: Brightness level
Empty and LED turn on lower than 200?

No

LCD display Lot 1: Yes Brightness level


Occupied and LED turn higher than 200?
off

No

Page 85 of 92
CARROT PROJECT BOARD USER MANUAL

Command Related

Command Command Function


Group
LCD_Show= On Graphic Show the LCD on the user interface
Design
Read_Controller Controller Read all sensors values from the project
I/O board
LCD_Text_Size= 30 Graphic Set text size on the LCD
Design
LCD_Show_Text= Text Graphic Clear and save new text in the memory of
Design LCD.
If C_Ain=0 Decision If a specific analog sensor value on the project
board matches with a specific condition
LCD_Back= Red Graphic Set LCD background with a specific colour
Design
End If Decision Terminate any if command
LCD_ Update Graphic Display the memory content of the LCD
Design
Dout1= On Controller Turn on or off DOUT output on the project
I/O board
Goto=1 Other Jump to a specific line.

Wiring

DOUT1 +

GND -

Page 86 of 92
CARROT PROJECT BOARD USER MANUAL

Program Description

LINE 1: LCD_Show = On To display LCD on user interface.

To read the brightness level sensor (light


LINE 2: Read_Controller
dependent resistor) value.

LINE 3: LCD_Text_Size = 60 To set the font size on the LCD to 70.

LINE 4: If C_Ain1 <= 200


If the brightness level is lower than 200,
LINE 5: LCD_Show_Text = Lot 1: Occupied the LCD will display Lot 1: Occupied and
the LED will turn off to indicate that the
LINE 6: Dout1 = Off parking is not available.
LINE 7: End If

LINE 8: If C_Ain1 > 200


If the brightness level is higher than 200,
LINE 9: LCD_Show_Text = Lot 1: Empty the LCD will display Lot 1: Empty and the
LED will turn on to indicate that the
LINE 10: Dout1 = On parking is available.
LINE 11: End If

To display the content of the LCD.


LINE 12: LCD_Update

Jump to LINE 1 and execute the program


LINE 13: Goto = 1 again.

Page 87 of 92
CARROT PROJECT BOARD USER MANUAL

Program Operation

The diagram below shows the flow of the program when the parking is empty.

LINE 1: LCD_Show = On

LINE 2: Read_Controller
LINE 3: LCD_Text_Size = 60

LINE 4: If C_Ain1 <= 200

LINE 5: LCD_Show_Text = Lot 1: Occupied

LINE 6: Dout1 = Off


LINE 7: End If

LINE 8: If C_Ain1 > 200

LINE 9: LCD_Show_Text = Lot 1: Empty

LINE 10: Dout1 = On


LINE 11: End If

LINE 12: LCD_Update

LINE 13: Goto = 1

Page 88 of 92
CARROT PROJECT BOARD USER MANUAL

The diagram below shows the flow of the program when the parking is occupied.

LINE 1: LCD_Show = On

LINE 2: Read_Controller

LINE 3: LCD_Text_Size = 60
LINE 4: If C_Ain1 <= 200

LINE 5: LCD_Show_Text = Lot 1: Occupied

LINE 6: Dout1 = Off

LINE 7: End If
LINE 8: If C_Ain1 > 200

LINE 9: LCD_Show_Text = Lot 1: Empty

LINE 10: Dout1 = On

LINE 11: End If


LINE 12: LCD_Update

LINE 13: Goto = 1

Page 89 of 92
CARROT PROJECT BOARD USER MANUAL

Exercise 10
Upgrade the system with 2 parking lots.

Add a brightness sensor at Ain2 to detect car.

The system will display 'Lot 2: Occupied' on the LCD and turn on LED (at Dout2) when lot 2 is
occupied.

The system will display 'Lot 2: Empty' on the LCD and turn off LED (at Dout2) when lot 2 is
not occupied.
Youtube Video Link: https://youtu.be/xr-KegSMPMA

Wiring

AIN 2
5V +

GND -

DOUT2 +

Page 90 of 92
CARROT PROJECT BOARD USER MANUAL

Answer

LCD_Show = On

Read_Controller

LCD_Text_Size = 60

If C_Ain1 <= 200

LCD_Show_Text = Lot 1: Occupied

Dout1 = Off

End If

If C_Ain1 > 200

LCD_Show_Text = Lot 1: Empty

Dout1 = On

If C_Ain2 <= 200

LCD_Add_Text = #Lot 2: Occupied

Dout2 = Off

End If

If C_Ain2 > 200

LCD_Add_Text = #Lot 2: Empty

Dout2 = On

End If

LCD_Update

Goto = 1

Page 91 of 92
CARROT PROJECT BOARD USER MANUAL

Relay Module Wiring

Relay Module 12V LED Lamp


-

5V +

8AA Battery

12V Adapter Dout1

GND

Page 92 of 92

Vous aimerez peut-être aussi