User Tools

Site Tools


languages:visual

Table of Contents

Visual Programming

This language is based on Google Blockly and its purpose is learning. While writing your program in Visual Programming, you can see the Python output.

This page presents the specific blocks that we added for Wyliodrin. For other blocks, please read the Blockly Language tutorials:

You can try the language on the Wyliodrin Projects page.

Here are some the blocks that you can use:

Screen and keyboard

Print

Print a text on the screen and put the cursor on a new line

Write

Write a text on the screen and keep the cursor on the same line

Write and read

Write a text on the screen and ask the user for a text, integer number or real number from the keyboard.

This block results in a value that can be either stored into a variable or used as in input for another block.

Read

Ask the user to enter a text, integer number or real number from the keyboard.

This block results in a value that can be either stored into a variable or used as in input for another block.

Pins

These blocks allow you to control the board's pins. Depending on the board, each pin has a number. You may read more about this on the pins layout page.

Set Pin

Set a digital value on a pin.

You have to add the pin number and the value you want.

  • HIGH means 1
  • LOW means 0

Read Pin

Read the value from a pin.

The block results in a value

  • 1 if the value of the pin is HIGH (it receives a voltage on the pin)
  • 0 if the value of the pin is LOW (it receives no voltage on the pin)

Shift Out

Writes a value serially on a pin.

This will send out a value bit by bit the data pin and generate a clock signal on the clock pin. It will start with the LSB (Least Significant Bit).
Usually this function is used with shift registers. You have an example on the Arduino ShiftOut page.

Shift In

Reads a value serially from a pin.

This block results in a value read serially from the data pin, using the clock generated on the clock pin. It will start with the LSB (Least Significant Bit).
This is used with shift registers. You have an example on the Arduino ShiftIn page.

Advanced

These blocks allow advanced operations on pins.

Pin Mode

Sets the pin in INPUT/OUTPUT mode. If the pin is set as INPUT, then it is used to read values from sensors, otherwise, the pin is used to drive other devices.

Digital Write

Set a digital value on a pin. The block is similar to Set Pin.

Digital Read

Read the value from the pin. The block is similar to Read Pin.

Analog Write

Set a value between 0 and 255 on the pin.

Analog Read

Read a value between 0 and 255 from the pin.

Timing

These blocks are used for delaying or measuring time parameters.

Delay

This will delay the program execution for a period of seconds, milliseconds or microseconds.

Millis

This will result in the number of milliseconds since the start of the program.

Micros

This will result in the number of microseconds since the start of the program.

LED

You can light LEDs in differenc colours with these blocks.

Set LED

Sets On/Off the LED on the pin of the value transmitted. When the LED is On, it lights and Off will turn it off. The block is equivalent to the Set Pin block.

Set Basic Color

Sets the LED with the specified pins for RGB at the selected color. The color must be one of the eight basic colors that are in the Colors menu.

Set Fine Color

Sets the LED with the specified pins for RGB at the selected color. The color can be any of any kind. This block can be used only if the pins used are PWMs.

Multimedia

You can make noise using these blocks.

Load

Returns an Audio Stream variable. Most of the others functions request this type of variable as a parameter. The Audio Stream can be created from a file, in this case the second parameter will be the file's name, or from a URL and the second parameter will be the address.

Example of how the Audio Stream variable is created:

Play

Plays an Audio Stream.

Pause

Pause or resume the player.

Stop

Stops the player

Is Playing

Verifies whether the player is playing

The result is True if it is playing and False if not.

Stream Level

Returns the power of the Audio Stream at a certain moment. It ranges from 0 to the maximum value passed through the second parameter. If there is no sound, the value is 0, if it is maximum, the value is equal to the second parameter.

Position

Returns the specific moment of the Audio Stream being played. The moment can be represented in seconds or in bytes.

Set Position

Sets the specific moment the to play the Audio Stream.

Audio Stream Volume

Returns the Audio Stream's volume.

The minimmum value is 0 and the maximum value is 100.

Set Audio Stream Volume

Sets the Audio Stream's volume.

The minimmum value is 0 and the maximum value is 100.

Set Volume

Sets the board's volume. The minimum value is 0 and the maximum value is 100.

Volume

Returns the board's volume. The minimum value is 0 and the maximum value is 100.

On some boards, volumes are not linear, meaning it does not grow proportional with the number. It needs to be at least 50 to hear.

Setting a higher value than 100 will result in an error.

Rapiro

These blocks allow Rapiro robot movement.

Walk

Instructs Rapiro to walk forward or backwards for an amount of time.

Turn

Instructs Rapiro to turn left or right for an amount of time.

Stop

Instructs Rapiro to stop from what it is doing and pause.

Turn

Instructs Rapiro to wave its hand for an amount of time.

Move

Instructs Rapiro to move its servos in an amount of time

The servos are:

Servo Right Left
Head 0 180
Waist 0 180
Servo Low Up
Right Shoulder 0 180
Right Arm 40 130
Left Shoulder 180 0
Left Arm 30 140
Servo Close Open
Right Hand 140 50
Left Hand 120 50
Servo Left Right
Right Foot Yaw 40 140
Right Foot Pitch 40 140
Left Foot Yaw 40 180
Left Foot Pitch 40 140

Eyes Color

Instructs Rapiro to change its eyes color in an amount of time

LEGO Mindstorms

Blocks for LEGO Mindstorms

LEGO Run Motor

Sets the speed/power of the motor connected on a port. Ports can be from 1 to 4. The ports are described on the BrickPi website.

Motors will not change speed until values are not updated using LEGO Update Values.

LEGO Update Values

Sends the motors speed/power and reads the sensor values.

LEGO Startup Sensors

This block sets up the sensors. Use this block before any sensors.

LEGO Touch Sensor

Reads the value from a touch sensor connected to the BrickPi. Returns 1 if it is pressed and 0 if not.

In our tests we have determined that this works in the following way: use two touch sensor bricks connected on port 1 and 2 or 3 and 4. One of them will give you a valid value.

LEGO Light Sensor

Reads the value from a light (color) sensor connected to the BrickPi.

LEGO Ultrasonic Sensor

Reads the value from a ultrasonic (distance) sensor connected to the BrickPi.

GROVE Kit

Pins

Set Pin

Sets a digital value on one of the digital pins(D2 to D8).
High means 1 and Low means 0.

Read Pin

Reads a value from one of the digital pins and returns 0 or 1.

Set PWM Pin

Sets a value between 0 and 255 on one of the PWM Pins(pins 3, 5 and 6).

Read Analog Pin

Read a value between 0 and 255 from a analog pin(A0 to A3).

LED

Set LED

Sets On/Off the LED on one of the digital pins(D2 to D8).

Set LED Brightness

Sets the LED's brightness with the specified value.

Button

Set Button

Sets to Pressed/Released the button on the pin. Pressed means 1 and Released means 0.

Button Switched

Changes the state of the button to Pressed/Released.

Potentiometer

Returns a value between 0 and 300 degrees from the potentiometer on one of the analog pins(A0 to A3).

Buzzer

Set Buzzer

Sets to High/Low the buzzer on one of the digital pins, where High is 1 and Low is 0.

Set Buzzer Volume

Sets to a specified volume the buzzer on the digital pins.

Touch

Set Touch

Sets to Pressed/Not Pressed the touch on the pin, where Pressed is 1 and Not Pressed is 0. This block is similar to Set Button.

Touch Switched

Switches the current state of the touch to Pressed/Released.

Sound Sensor

Get Volume

Reads a value from the analog pin and returns the volume.

Temperature Sensor

Get Temperature

This block returns the temperature in Celsius degrees from the sensor on one of the analog pins.

Get Temperature in Fahrenheit

Returns the temperature in Fahrenheit degrees from the sensor on one of the analog pins.

Light Sensor

Get Light

Returns a value between 0 and 1023 from the sensor on one of the analog pins depending on ambient light.

Alcohol Sensor

Get Alcohol value

It returns the value of alcohol read from one of the analog pins(A0 to A3).

UV Sensor

Get UV value

The block returns the UV value from one analog pin(A0 to A3).

Motion Sensor

Get motion

The digital sensor returns a value of 1 or 0 depending on if someone is around or not.

Vibration Sensor

Get Vibration Value

The block returns the value of vibrations from the analog pin specified.

Water Sensor

Get Water

It returns 0 if there is no water or 1 if the digital sensor detects water.

Moisture Sensor

Get Moisture value

The block returns moistures value from one of the analog pins.

LCD

The LCD works only on one of the 4 I2C pins.

Set LCD

Initialize the LCD with 1, 2 or 4 rows and 16 or 20 columns.

Prints on the LCD the text you typed.

Set LCD Cursor

Sets the cursor at a specified row and column.

Set LCD color

The block sets the LCD's color.

Turn LCD On

Turns On the LCD.

Turn LCD Off

Turns Off the LCD.

Turns On the blinking cursor.

Turns Off the blinking cursor.

LCD Cursor On

Turns On the LCD's cursor.

LCD Cursor Off

Turns Off the Cursor.

LCD Scroll Left

The block scrolls the text to left.

LCD Scroll Right

The block scrolls the text to right.

LCD Right to Left

Sets the text direction right to left.

LCD Left to Right

Sets the text direction left to right.

LCD Autoscroll On

Turns On the autoscroll of the text.

LCD Autoscroll Off

Turns Off the autoscroll of the text.

Relay

Set Relay

Sets to On/Off the relay on the pin.

Get Relay State

Returns the state of the relay on the pin.

Servo

Sets servo's angle on the pin.

Social

E-mail

Setup

For the e-mail setup block you have to choose between gmail, yahoo and hotmail. Then you have to type your e-mail address and your password.

Send mail

To send an e-mail you just have to write the receiver's address, the e-mail subject and your message.

Facebook

Before using any other Facebook block, you need the Setup block. Without it, you cannot run your program.

Setup

If you want to use Facebook blocks, you will need to do the setup and generate an Access Token.
For this, click here: https://developers.facebook.com/. You have to log in, click on Tools - Graph Explorer - Get Access Token. Depending on what you want to do, you will check different options. Copy the generated access token into the field and choose the next block.

Post

You can post if you go on Extended Permissions and check the publish_actions option. You can use this access token for the Setup block. In the special field, write what you want to post.

The following 5 blocks are not supported in JavaScript.

Get notifications

The block returns your notifications. For this, you have to go to Extended Permissions and choose manage_notifications.

Get friends list

It returns a list with your Facebook friends. For this block you need a different token witch you can generate if you check user_friends.

Get a friend

If you write a number, it will return a specific friend from your friends list.

Get number of Likes

The block will return the number of Likes from the specified page.

Get post from group

For this block you will need to generate an access token with user_groups option checked.
It will return all posts from the group that you want.

Twitter

Before using any other Twitter block, you need the Setup block. Without it, you cannot run your program.

Twitter Setup

For the setup block we will generate 4 Access Tokens.
We will start from your standard account. On the right side of the page you have a box with some options. It looks like this and you have to click on Developers.
After that, you have to enter in My applications section. If it is the first time you access this section, you have to creat an application. When you have your own Twitter App, click on API Keys, from where you will generate your keys.
But before that, you should modify the Access level. By default it is Read only, but if you want to tweet, you have to extend it.
After saving the changes, you should see the Test OAuth button on top of the page, on the right side. By clicking it, you will have all 4 access tokens. From now on you can have fun with our Twitter blocks.

Tweet

You just have to write the text in the special field. But make sure that you have the right Access level for your tokens( Read and Write or Read, Write and Access direct messages ).

Get timeline

This block is not supported in JavaScript.

It returns a list with your notifications.

Twilio

Before using any other Twilio block, you need the Setup block. Without it, you cannot run your program.

Setup

For this block we will need only two tokens. You just have to log in and you should see Account Sid and Auth Token. For the last one, you have to click on the lock to see the token.

Make a call with music

You can call a friend with this block. Write the receiver's phone number, your number(but make sure you used your country's code) and the music's URL.

Make a call

It calls at the phone number that you specified. Like for the other block you should use your country's code, otherwise it won't work. The interesting part of this block is that you can write something in the “Say” field, choose a language and instead of music, your friend will hear what you wrote.

Send a SMS

You specify the receiver's phone number, your number and the message.

The following 4 blocks are not supported in JavaScript.

Get call list

It returns a list of all your calls.

Get a call

It returns the call with the number that you specified from the call list.

Get SMS list

The block returns a list of all your messages.

Get a SMS

It returns from the SMS list the one with the number that you wrote.

Weather

Init Weather API

It stores the key you retrieve from openweathermap.org
In order to get the API key, you need to create a free account on http://openweathermap.org/appid. Sign up and on your account page you will have the API key.

Get weather by city

It returns the value of the chosen parameter(temperature, humidity, pressure, wind speed) when you write a city name in the text field.

Get weather by coordinates

The block is similar to the previous one, but instead of specifying the city name, you fave to write the latitude and longitude coordinates of it.

languages/visual.txt · Last modified: 2016/02/29 12:46 by ioana.culic