Visualising button presses on MIT App

As many strings as buttons have been pressed before there has been no button presses for 15s. If 6 buttons have been pressed, and then for 15s no buttons pressed, then 6 strings will be sent for example.

Thank you so much for the example, that helps a lot! The buttons will be pressed randomly unfortunately

Before diving in to how to receive and process your sheet music, let me first point out some mistakes in your blocks.

  1. You are missing the step where you take the chosen item from the list of stringValues and split it at commas into global lijst (which needs a more expressive name, like note_parts).
  2. Don't confuse string length (number of characters) with list length (number of items).
  3. The Is Number block returns true or false, and is good for validating numerical data, but is not meant to be stored as the number itself.

And I tried this, but the string value does not get accepted as a number, as the string value is received as text, if that makes sense haha, how could I fix that?

This project gets easier if you divide it into three stages:

  1. Receiving the sheet music via BLE, and saving it into a 3 column table (button number, start seconds, duration seconds)
  2. Transform the sheet music table into a program table for step 3, with three columns (deadline in milliseconds from start of piece, indicator (button) number, indicator color). This table should have twice the number of rows as the sheet music table, and should be sorted in ascending deadline order.
  3. Play the program table under control of a fast clock, keeping a start time in a global variable. Each cycle, if the program table is not yet an empty list, compare SystemTime - start time against the item 1 deadline. If due, do its color change and remove item 1. Otherwise do nothing this clock cycle.

I really appriciate your help! Only problem is I fear I am not smart enough to understand all this haha.

For the project we are programming a smart skateboard, which can detect your footprint and replay it on your phone, which I am making (a very simple version with only 4 sensors, or buttons to keep it simple for now) in the MIT app. Each button is like a sensor that detects your footprint, and that order and length should be shown on the phone.

The sheet music reference gets quite confusing (especially as English is not my native language:)

Now your app looks more like a stacked bar chart, one stack per sensor, with height mapping to duration.

AI2 has a stacked bar chart component:

I don't think so, the app looks like this:


As you see 4 gray canvasses, and each corresponding to a button. The canvas should light up when the corresponding button has been pressed.

App Inventor sees "text numbers" as numbers. If that isn't happening, there must be a tiny issue somewhere, perhaps the string itself, perhaps the text, perhaps the character encoding (UTF8 or ASCII are best for this).

A quick fix can be to add zero to the text number.

Tried that but this is the error I receive: The operation select list item cannot accept the arguments: , [[com.google.appinventor.components.runtime.Canvas@1cede58, com.google.appinventor.components.runtime.Canvas@ce3abb1, com.google.appinventor.components.runtime.Canvas@a87fc17, com.google.appinventor.components.runtime.Canvas@b7f8804]], ["["01"]

but you error says list of lists for list also the index too is in list it seems

Tried that but this is the error I receive: The operation select list item cannot accept the arguments: , [[com.google.appinventor.components.runtime.Canvas@1cede58, com.google.appinventor.components.runtime.Canvas@ce3abb1, com.google.appinventor.components.runtime.Canvas@a87fc17, com.google.appinventor.components.runtime.Canvas@b7f8804]], ["["01"]

also the index place is not strutured properly

This is the cause of that error:

The BLE stringValues is a list of incoming string messages (though I have yet to see it exceed one item.)

If you try to do a text operation like SPLIT on a list, AI2 translates the list into text, JSON by default. So the list becomes [01,...,...] and you are presented with "[01 as item 1 of the split result.

The solution to this is to apply the split to only one item of stringValues, usually in a For Each Item in List stringValues loop.

1 Like

Like this:

MultiClocks.aia (201.4 KB)

As you can see, the fault there is that wayward ["["01"]

I think we need to see the Script for the ItsyBitsy.

I fixed it, it works now!!! Due to your help:)) Thank you so so much!!!

1 Like

Could you show us how you fixed it?

It would settle a bet.

Yes of course! Here is the complete code I used for the app:)

Thank you.

This settles my bet:

image

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.