K 1 K 2 Manual
K 1 K 2 Manual
K 1 K 2 Manual
Website: www.magnetcode.com
Email: [email protected]
Bizchip Technology Centre 3363-2, JALA N 18/31, TAMA N SERI SERDA NG, 43300 SERI KEMBANGA N, SELANGOR.
Table of Content
Ref. Content Page
1 Install Magnetcode 3
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
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
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
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
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
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
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
Example 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
User can set title, background, buttons and LCD components in the graphic design page by
using related commands.
Title Background
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
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.
Start
Edit commands
Stop
Page 12 of 92
CARROT PROJECT BOARD USER MANUAL
STEP 1 STEP 2
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.
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.
Page 14 of 92
CARROT PROJECT BOARD USER MANUAL
STEP 5 STEP 6
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
.
Page 16 of 92
CARROT PROJECT BOARD USER MANUAL
STEP 9 STEP 10
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
Page 18 of 92
CARROT PROJECT BOARD USER MANUAL
For project 1, we will change the background colour from red to green every 500
milliseconds.
Start
Red background
Green background
Page 19 of 92
CARROT PROJECT BOARD USER MANUAL
Command Related
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
Page 21 of 92
CARROT PROJECT BOARD USER MANUAL
Program Operation
The diagram below shows the flow of the Emergency Light program.
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.
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
For project 2, we will program digital door sign Open blinking every 1 second.
Page 24 of 92
CARROT PROJECT BOARD USER MANUAL
Command Related
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
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 7: LCD_Update
LINE 9: LCD_Clear
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.
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
For project 3, we will create a digital clock that will display time on the LCD.
Start
Page 29 of 92
CARROT PROJECT BOARD USER MANUAL
Command Related
Page 30 of 92
CARROT PROJECT BOARD USER MANUAL
Program Description
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 5: LCD_Update
LINE 7: Goto = 1
Page 32 of 92
CARROT PROJECT BOARD USER MANUAL
Exercise 3
Answer
LCD_Show = On
LCD_Align = Middle
LCD_Add_Var = Time
LCD_Add_Var = Date
LCD_Update
Timer = 1 sec
Goto = 1
Page 33 of 92
CARROT PROJECT BOARD USER MANUAL
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
Page 35 of 92
CARROT PROJECT BOARD USER MANUAL
Item Function
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).
ONOFF3 On off servo motor 1 and servo motor2 through an external switch.
PL2 External power on off indicator for the carrot project board.
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.
Digital Output DOUT1, 2, 3, 4, 5 and 6 are digital outputs of the project board.
Page 36 of 92
CARROT PROJECT BOARD USER MANUAL
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.
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).
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
* Note:
1. TTL voltage level uses 0V for logic 0 and uses 5V for logic 1.
Page 39 of 92
CARROT PROJECT BOARD USER MANUAL
Pin Feature
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
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
Turn on red color LED (at Dout1) for 1 sec, then turn off red color LED for 1 sec.
Start
Red LED on
Page 42 of 92
CARROT PROJECT BOARD USER MANUAL
Command Related
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
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 5: Goto = 1
Page 45 of 92
CARROT PROJECT BOARD USER MANUAL
Exercise 4
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
Turn off white color LED (at Dout1) when button B1 is pressed.
Start
No
No
Page 48 of 92
CARROT PROJECT BOARD USER MANUAL
Command Related
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 7: ButtonB1_Show = On
To display White Off button for user to
LINE 8: ButtonB1_Show_Text = White Off press.
LINE 9: ButtonB1_Update
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 3: ButtonA1_Update
LINE 5: Dout1 = On
LINE 6: End If
LINE 7: ButtonB1_Show = On
LINE 9: ButtonB1_Update
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 3: ButtonA1_Update
LINE 5: Dout1 = On
LINE 6: End If
LINE 7: ButtonB1_Show = On
LINE 9: ButtonB1_Update
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 3: ButtonA1_Update
LINE 5: Dout1 = On
LINE 6: End If
LINE 7: ButtonB1_Show = On
LINE 9: ButtonB1_Update
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.
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_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_Update
If ButtonB2 = Pressed
Dout2 = Off
End If
Goto = 1
Page 55 of 92
CARROT PROJECT BOARD USER MANUAL
Turn on white LED (at Dout1) when door sensor (at Din1) is detected closed.
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
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
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 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 7: End If
LINE 8: Goto = 1
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.
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
Design a visitor counter to increase counter value with 1 when door sensor (at Din1)
is open and closed.
Start
Yes
Door is open and
Counter increase by 1 closed?
No
Page 63 of 92
CARROT PROJECT BOARD USER MANUAL
Command Related
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.
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
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 9: LCD_Update
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 9: LCD_Update
Page 67 of 92
CARROT PROJECT BOARD USER MANUAL
Exercise 7
Upgrade the project with a reset button (at Din2).
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
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.
Start
Display current
brightness level
Yes
LCD background turn Brightness level
green lower than 127?
No
No
Page 70 of 92
CARROT PROJECT BOARD USER MANUAL
Command Related
Wiring
5V
AIN1
GND
Page 71 of 92
CARROT PROJECT BOARD USER MANUAL
Program Description
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.
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 7: End If
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 7: End If
LINE 8: If C_Ain1 > 127
Page 74 of 92
CARROT PROJECT BOARD USER MANUAL
Exercise 8
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
LCD_Back = Green
Dout1 = Off
End If
LCD_Back = Red
Dout1 = On
Dout1 = Off
End If
LCD_Update
Goto = 1
Page 76 of 92
CARROT PROJECT BOARD USER MANUAL
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.
Start
No
No
No
Page 77 of 92
CARROT PROJECT BOARD USER MANUAL
Command Related
Wiring
PULSE1 +
GND -
Page 78 of 92
CARROT PROJECT BOARD USER MANUAL
Program Description
LINE 6: End If
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
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 5: Pulse1 = 0
LINE 6: End If
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 5: Pulse1 = 0
LINE 6: End If
LINE 7: If C_Ain1 >= 160
Page 82 of 92
CARROT PROJECT BOARD USER MANUAL
Exercise 9
Display 'Dim' on the LCD when brightness sensor's value is >=160 and <200
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 <200
LCD_Show_Text = Dim
LCD_Back = Orange
Pulse1 = 5
End If
LCD_Show_Text = Dark
LCD_Back = Red
Pulse1 = 100
End If
LCD_Update
Goto = 1
Page 84 of 92
CARROT PROJECT BOARD USER MANUAL
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.
Start
Yes
LCD display Lot 1: Brightness level
Empty and LED turn on lower than 200?
No
No
Page 85 of 92
CARROT PROJECT BOARD USER MANUAL
Command Related
Wiring
DOUT1 +
GND -
Page 86 of 92
CARROT PROJECT BOARD USER MANUAL
Program Description
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
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 7: End If
LINE 8: If C_Ain1 > 200
Page 89 of 92
CARROT PROJECT BOARD USER MANUAL
Exercise 10
Upgrade the system with 2 parking lots.
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
Dout1 = Off
End If
Dout1 = On
Dout2 = Off
End If
Dout2 = On
End If
LCD_Update
Goto = 1
Page 91 of 92
CARROT PROJECT BOARD USER MANUAL
5V +
8AA Battery
GND
Page 92 of 92