I'm trying to create a project with my digispark where i can iterate through an hashmap, when i press the push button the digispark writes via digikeyboard the values from an hashmap. Each time i press the button it's supposed to write the first value, then i press the push button again and in the same line it cleans what was written in the first value and writes the second value and so on. when the last value is reached it goes again to the first value if the button is pressed. Right now i'm trying to put the iterator to work preperlly, this is the code i have:
#include "DigiKeyboard.h"
#include "HashMap.h"
HashMap<String, String> hashMap;
int i = 0;
void setup() {
//setup hashmap
hashMap.put("key0","test0");
hashMap.put("key1","test1");
hashMap.put("key2","test2");
hashMap.put("key3","test3");
hashMap.put("key4","test4");
DigiKeyboard.sendKeyStroke(0);
pinMode(0, INPUT);
}
void loop() {
int sensorValue = digitalRead(0);
while(sensorValue ==1 and i < hashMap.count())
{
delay(100);
DigiKeyboard.println( hashMap.valueAt(i));
i++;
}
}
when i plug the digispark it prints automatically the first and the second value ("test0" "test1") and every time i press the button i get nothing.
This is my configuration: http://cdn.instructables.com/FZA/0UN8/HI3TXV8D/FZA0UN8HI3TXV8D.LARGE.jpg
Can anyone help me please?
loop()
and understand fully what it does. Try explaining what each line does to someone else. – Ignacio Vazquez-Abrams Nov 7 '16 at 15:17