(RB-13K033)Getting Started with Processing kit

From ALSRobot-Wki
Jump to: navigation, search
13K03301.png

Contents

Product overview

The Getting Started with Processing Kit is produced by Harbin Alseon Robotics Technology Co.,Ltd. Processing is an open source programming language and environment for people who want to create images, animations, and interactions. Initially developed to serve as a software sketchbook and to teach fundamentals of computer programming within a visual context, Processing also has evolved into a tool for generating finished professional work. Today, there are tens of thousands of students, artists, designers, researchers, and hobbyists who use Processing for learning, prototyping, and production. Although you did not learn the programming language of the host computer electronic circuit or VB, VC, Delphi, etc, you can still follow the product instructions operation to do experiment step by step. Through the operation of each experiment, you can achieve the interaction between the sensor and Processing easily by the interface of 3P sensor cable and sensor expansion board. This kit not only includes all the example of detailed notes program in Getting Started with Processing kit, but also includes Processing, Arduino IDE, Fritzing serial debugging assistant and other commonly used software.

Packing List

  • 1 x Carduino UNO R3 Controller
  • 1 x Sensor Shield v5.0 for Arduino
  • 1 x USB Cable A-B for Arduino
  • 1 x Digital Push Button
  • 1 x Analog Rotation Sensor
  • 1 x Light Sensor
  • 1 x PS2 Dual-Axis Joystick
  • 1 x LM35 Temperature Sensor
  • 1 x Flame Sensor
  • 1 x Buzzer module
  • 1 x Digital Magnetic Sensor
  • 1 x RB URF02 Ultrasonic Sensor
  • 1 x TCS3200 Color Sensor
  • 3 x Mini IR Line Tracking Sensor
  • 1 x LED Module (color: green)
  • 1 x LED Module (color: red)
  • 1 x LED Module (color: yellow)
  • 5 x 3Pin Jumper Wire
  • 10 x Jumper Wire
  • 1 x Supporting data and disc

Carduino UNO Technical Parameters

  1. Microcontroller:ATmega328
  2. Flash RAM:32 KB (ATmega328, 0.5 KB of it is used for Bootloader)
  3. Operating Voltage:5V
  4. Input voltage:External power supply not required when USB connected or Input of 7V~12V DC
  5. Output voltage:5V DC Output, 3.3V DC Output and External power supply input
  6. Clock frequency:16 MHz
  7. Input voltage:7-12V(recommended)
  8. Input voltage:6-20V(limited)
  9. Supports USB Interface Protocol and power supply(External power supply not required)
  10. Supports ISP download
  11. Digital I/O interface:14(6 PWM Output port)
  12. Simulation input interface:6
  13. DC Current:40mA(I/O Pin)
  14. DC Current:50mA(3.3V Pin)
  15. EEPROM:1 KB (ATmega328)
  16. SRAM:2 KB (ATmega328)
  17. Size:75x55x15mm

Programming Introduction

Processing software introduction

1.Software download and installation
Processing software download link
The software can be used once it is unzipped without any installation process. The newest update version is 3.0

2.Processing User instruction
Simply double click Processing.exe, the following program compiling window will be showed:

13K03302.jpg

Toolbar shortcut button description:

  • No. 1:Used for testing Program running results and displaying works. Ctrl+R can be used as well。
  • No. 2:Stop execution: Click the button and stop the current running program.
  • No. 3:Create files: Click the button will open a new program window.
  • No. 4:Open: Click the button will make the name of Processing sample file and the file you created appear.
  • No. 5:Save: Click to save the current program code. The first operation requires to enter name and location of the file.
  • No. 6:Export: The export function will create an applet folder in the original path. The old version of Processing will generate several formats: html、gif、jar、java、pde.

Arduino IDE Software Introduction

Arduino Getting Started Tutorial
How to install Carduino UNO driver
Arduino Programming Guide

Processing basic language

Processing is similar to the development environment of Arduino, therefore it is more understandable than other programming softwares. The programming language is based on Java, but other languages can also be applied which make it simpler and more humanized.

Processing Program Basic Infrastructure

A Processing program can be divided into 2 parts as Arduino;
void setup()
Place the program that initialize Processing in this function and make the main loop program set up relevant parameters before beginning.
void draw()

This is the main function of Processing. The program will be executed repeatedly till click the stop button.
Note: The 2 parts are not necessarily included in the basic instructure of Processing program.

Methods of Use

First Processing Program

Run the software, copy the following code into the software, and then click the Run button, a output window will appear.

void setup()
{
size(500, 500);//设置画布大小500*500像素
}
void draw() {
if (mousePressed) {//检测鼠标按键是否按下
fill(0);//填充黑色
} else {
fill(255);//填充白色
}
ellipse(mouseX, mouseY, 60, 80);//以鼠标坐标为圆心画椭圆

Program effect:The output window displays as gray screen, and then move the mouse in the output window, follow the cursor's movement. Click the mouse, the oval turn to black and follow the cursor.

Processing interact with Arduino——the LED indicator

Hardware required

  • Arduino LED light emitting module Piranhas lights Green highlighting*1
  • Arduino LED light emitting module Piranhas lights Red Highlighting*1
  • Arduino LED light emitting module Piranhas lights Yellow Highlighting*1
  • Carduino UNO controller*1
  • Arduino Sensor Shield V5.0 Sensor expansion board*1
  • 3P Sensor connection wires *3

Sample Code

Processing Program:

import processing.serial.*;
Serial myPort;  // 创建串口名称
PFont font;//创建字体变量
void setup() 
{
    size(230, 200);//画布大小
    myPort = new Serial(this,"COM6",9600);//串口初始化
    font = createFont("楷体",48,true);//载入系统字体
}
void draw() {
  background(255);//背景颜色
  if (mouseOverRectR() == true) { // 判断鼠标是否在方块上
    fill(255,0,0);// 方块填充绿色
    myPort.write('R'); // 串口发送‘R’
    rect(20, 120, 50, 50);// 绘制一个方块
  }else{
    fill(125);
    rect(20, 120, 50, 50);// 绘制一个方块
    fill(255,0,0);// 方块填充蓝色
    textFont(font,50);//设置字体大小
    text("红", 20, 165);
    }  
  if (mouseOverRectG() == true) {// 判断鼠标是否在方块上
    fill(0,255,0);// 方块填充绿色
    myPort.write('G');// 串口发送‘G’
    rect(20+20+50, 120, 50, 50);// 绘制一个方块
  } else{
    fill(125);
    rect(20+20+50, 120, 50, 50);// 绘制一个方块
    fill(0,255,0);// 方块填充蓝色
    textFont(font,50);//设置字体大小
    text("绿", 20+20+50, 165);
    } 
  if (mouseOverRectY() == true) {// 判断鼠标是否在方块上
    fill(255,255,0);// 方块填充黄色
    myPort.write('Y');// 串口发送‘B’
    rect(20+20+50+20+50, 120, 50, 50);// 绘制一个方块
  }else{
    fill(125);
    rect(20+20+50+20+50, 120, 50, 50);// 绘制一个方块
    fill(255,255,0);// 方块填充黄色
    textFont(font,50);//设置字体大小
    text("黄", 20+20+50+20+50, 165);
    }
    fill(255,125,255); 
    textFont(font,25);//设置字体大小
    text("把鼠标移动到方块上", 3, 50);
}
boolean mouseOverRectR() { // 测试鼠标是否在方块上
  return ((mouseX >= 20) && (mouseX <= 20+50) && (mouseY >= 120) && (mouseY <= 120+50));
}
boolean mouseOverRectG() { // 测试鼠标是否在方块上
  return ((mouseX >= 20+20+50) && (mouseX <= 20+50+20+50) && (mouseY >= 120) && (mouseY <= 120+50));
}
boolean mouseOverRectY() { // 测试鼠标是否在方块上
  return ((mouseX >= 20+20+50+20+50) && (mouseX <= 20+50+20+50+20+50) && (mouseY >= 120) && (mouseY <= 120+50));
}

Copy the code above to Processing compiler, pay attention to the "COM6" should according to different needs of each UNO PC serial port. Arduino end program:

char val; // 串口接收寄存器
int Rled = 11; // 红色LED接在数字11引脚
int Gled = 12; // 绿色LED接在数字12引脚
int Yled = 13; // 黄色LED接在数字13引脚
void setup() {
   pinMode(Rled, OUTPUT); // 设置引脚为输出
   pinMode(Gled, OUTPUT); // 设置引脚为输出
   pinMode(Yled, OUTPUT); // 设置引脚为输出
   Serial.begin(9600); // 串口初始化
}
void loop() {
   if (Serial.available()) { // 判断串口是否有数据
   val = Serial.read(); // 读回来的数据存储在val中
   }
   if (val == 'R') { // 判断读取的是否是"R"
     digitalWrite(Rled, 255); // 点亮红灯
   } else{
       digitalWrite(Rled, 0); // 关掉红灯
     }
   if (val == 'G') { //判断读取的是否是"G"
     digitalWrite(Gled, 255); // 点亮绿灯
   } else{
       digitalWrite(Gled, 0); // 关掉绿灯
     }
   if (val == 'Y') { // 判断读取的是否是"Y"
     digitalWrite(Yled, 255); //点亮黄灯
   } else{
       digitalWrite(Yled, 0); //关掉黄灯
     }
}

Program effect:After connecting Arduino controller, click on the Run button and move the mouse in output window. When the mouse is on the red square, the red LED module light up. On the green square, green LED lights up, on the yellow square, yellow LED lights up. Program effect diagram:

13K03304.jpg

Selection of Video

Processing 01.png
Processing 02.png


Products related to recommend

Erweima.png

Purchase link

Getting Started with Processing Kit

Related documents

Getting Started with Processing kit Video Collection
Arduino and Processing communication
Alsrobot Technical Forum

Personal tools
Namespaces

Variants
Actions
Navigation
Tools