Tag Archives: appinventor

“Why Learning to Code is So Damn Hard”

Click through for the full post at Viking Code School – as they say, the early part can be easy, then things get tougher, followed by a challenging learning period – until confidence and skills flourish.

What every beginner absolutely needs to know about the journey ahead

Source: Why Learning to Code is So Damn Hard

MIT App Inventor makes many things easier – but eventually one must learn to think like a software developer and become familiar with concepts like data structures, algorithms, design patterns, and software engineering design and project management.

How to connect App Inventor apps to Arduino using Bluetooth wireless

How to Connect App Inventor apps to Arduino Using Bluetooth

Bluetooth is a low power, short range wireless technology built in to many phones, tablets and other devices.

MIT App Inventor 2 supports a set of Bluetooth communication functions that may be used to send data between smart phones and tablets (see previous tutorials: Part 1, Part 2)

This capability may be extended so that App Inventor apps can communicate with Arduino-based devices and other embedded systems.

This tutorial describes how to interface App Inventor apps running on Android to Arduino devices, via the Bluetooth wireless link.

What is Bluetooth?

Bluetooth is an industry standard for low power, short range wireless communications between devices such as personal computers, printers, smart phones, tablets, wireless headphones, wireless stereo speakers, sensor systems (like in security alarms) and other applications.

To learn more about Bluetooth technology (and why it has a funny name!), please read our first tutorial on Bluetooth.

What is Arduino?

Arduino is an open hardware, open software platform for building small electronic devices. The Arduino board is a “microcontroller” – that is, a complete – albeit small, inexpensive and with limited function – computer. Arduino is a popular choice for do-it-yourself projects and is well established in the “Maker” community of DIY project builders. (Side note: I will be at the San Francisco Maker Faire on Saturday, May 16th, 2015).

This is not a tutorial about Arduino boards, software or electronics and presumes the reader is familiar with Arduino development. To learn more about Arduino (and you should learn more about it!) start at the Arduino web site.

This tutorial assumes you have the Arduino software development environment installed on your computer and are familiar with Arduino development.

HARDWARE: Setting Up Arduino for Bluetooth Wireless Communications

There are several versions of the Arduino board; I used the Uno version but others should work just fine.

The Arduino board does not contain Bluetooth hardware – to implement Bluetooth requires using a third-party Bluetooth module. I use the JY-MCU Bluetooth module . IMPORTANT – not all Bluetooth modules will work with App Inventor!  While new versions of Android support all versions of Bluetooth, App Inventor (at the time of this writing) supports “classic” Bluetooth only. In particular, App Inventor does not support the newer Bluetooth LE (Low Energy) version, at least it does not support the Bluetooth LE module that I have.

I can confirm that the JY-MCU Bluetooth module works but the Bluetooth LE modules I have do not work with App Inventor.  My phone can see the Bluetooth LE device but the App Inventor source code cannot communicate with the LE devices.

Where to buy the JY-MCU Module online: Amazon (Prime), Amazon (non-Prime)

The module is also available from other vendors.

Photo shows my Arduino UNO board, at left, a prototyping breadboard with a status LED set up, and the JY-MCU Bluetooth module, just above the breadboard.

DSC_1266Click through to  see how the Arduino and Bluetooth module are setup, and get the Arduino source code and the App Inventor source code!

Continue reading How to connect App Inventor apps to Arduino using Bluetooth wireless

Coming soon: Bluetooth to connect Android App Inventor code to Arduino

I  have an App Inventor app running on my Nexus 5 and talking to an Arduino board via Bluetooth. I finally had a chance to work on this!

UPDATE: Here is the link to the final code and tutorial information!

What I have  now is some experimental code not suitable for posting online. I will be revising this code to turn it into a simple example that will provide basic functionality, and then present a tutorial on putting it to use in your own applications.

Update Tuesday Cinco de Mayo (in the U.S.): I have the demo code up and running. Next up is to test and write up the tutorial! It’s coming! The first tutorial will be simple – intended to get you up and running.  I will eventually create some more advanced features.

Longer term, I may create a more general solution for passing data packets back and forth between an Android App Inventor app and an Arduino board, so that many types of applications may be supported using my basic code library.

Arduino is a small microcontroller board used by hobbyists and others to add computing to small devices, art projects, robots, Internet connected devices and much more. Arduino is not part of App Inventor. Arduino is, for an “embedded system” easy to use in terms of building electronics hardware and writing control software. By writing App Inventor code to talk to an Arduino board, we open an entire world of new possibilities using simplified development (App Inventor on Android, and Arduino on the hardware side).

  • Use your phone or tablet to remote control an Arduino device over a Bluetooth link
  • Use an Arduino device to monitor remote sensors, and then link sensor inputs to an Android phone over Bluetooth
  • Conceptually, an Arduino device could monitor local sensors (temperature, humidity, security alarms), and transmit sensor data to an Android phone, which, in turn, could forward the data onto an Internet location.

Using TimePicker and DatePicker for entering time and date information

The TimePicker and DatePicker User Interface Controls

Entering the date and time are common features of business applications. We could use a text edit box and let the user type in times (like 10:30) or dates (12 January 2015) but both methods require the user to enter the time or date in the proper format – and the app needs to test the entered data to ensure it was entered correctly.

A better solution is to use App Inventors TimePicker and DatePicker controls. Both provide a graphical method of selecting input values. For example, the TimePicker displays the following:

TimeDate_TimePickerUIThe time is set by pressing the + or – buttons above and below the hours and minutes. The AM/PM indicator is a toggle – when it shows PM, a press changes it to AM, and when it shows AM, a press changes it to PM. With this input system, the user can never entered an invalid time (the user could, of course, enter the wrong time, but that is a different problem!)

Continue reading Using TimePicker and DatePicker for entering time and date information

Displaying web pages in your Android apps

Last year, I presented a short tutorial on displaying web pages from inside your App Inventor apps. Now, here is a some what improved version that prompts for a web address URL, checks to see if http:// has been entered, and if not, prepends http:// to the front of the address. Then the web page is displayed.

The Designer View

There is not much to the user interface – a text box to enter the web URL and a button to display the web page. The page then appears below the button, and the content may be scrolled on the screen.

To create this user interface, drag a horizontal layout onto the screen and then add a label for the “Web page URL” prompt, followed by a text box for the data entry. Then add the Display web page button.

From the User Interface section of the Palette, at the left of the Designer screen, drag and drop a WebViewer component on to the design area.

Screenshot_2015-02-10-15-15-17

 

The WebViewer is not a full Internet browser – it is a component that displays the specified web page only. The WebViewer does not support standard browser features, such as saving web page content nor does it provide a history of the web pages visited.

The Blocks Code

Continue reading Displaying web pages in your Android apps

Blocks Editing Tip: Arranging and collapsing blocks in the editor

As you develop your App Inventor program using the Blocks editor, do you find your blocks overlapping and crashing in to one another on the screen? You know, like this:

AIBlockMess

You can drag the blocks on the screen so they no longer overlap, but dragging each block is tedious (time consuming). But there is an easy way to automatically re-arrange the blocks.

  • Move the mouse pointer to any part of the white space outside the blocks
  • On Windows, right-click the mouse button
  • On Mac OS X, press Ctrl and click the mouse button

Continue reading Blocks Editing Tip: Arranging and collapsing blocks in the editor