{"id":4499,"date":"2021-02-24T04:26:19","date_gmt":"2021-02-23T21:26:19","guid":{"rendered":"https:\/\/www.phidgets.com\/education\/?page_id=4499"},"modified":"2022-08-26T22:52:32","modified_gmt":"2022-08-26T15:52:32","slug":"true-or-false","status":"publish","type":"page","link":"https:\/\/www.phidgets.com\/education\/learn\/projects\/true-or-false\/","title":{"rendered":"True or False"},"content":{"rendered":"<p>[et_pb_section bb_built=&#8221;1&#8243; specialty=&#8221;off&#8221; next_background_color=&#8221;#000000&#8243; _builder_version=&#8221;4.4.1&#8243; custom_padding=&#8221;||0px|&#8221; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243;][et_pb_row _builder_version=&#8221;4.4.1&#8243; use_custom_gutter=&#8221;on&#8221; gutter_width=&#8221;3&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243;][et_pb_column type=&#8221;1_2&#8243; custom_padding__hover=&#8221;|||&#8221; custom_padding=&#8221;|||&#8221;][et_pb_code admin_label=&#8221;True or False&#8221; _builder_version=&#8221;4.6.6&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243;]<\/p>\n<div class=\"ph-overline-text\"><!-- [et_pb_line_break_holder] -->    <a href=\"\/education\/learn\/projects\">Projects<\/a><!-- [et_pb_line_break_holder] -->    <\/div>\n<p><!-- [et_pb_line_break_holder] --><\/p>\n<h1>True or False<\/h1>\n<p>[\/et_pb_code][et_pb_code admin_label=&#8221;Description&#8221; _builder_version=&#8221;4.6.6&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243;]<pee>Use your Getting Started Kit to create a True or False game!<\/pee>[\/et_pb_code][et_pb_code admin_label=&#8221;ph-button-cta: Start&#8221; _builder_version=&#8221;4.4.1&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243;]<a class=\"ph-button-cta\" href=\"#setup\"><!-- [et_pb_line_break_holder] -->  <\/p>\n<div class=\"ph-button-cta__icon\"><\/div>\n<p><!-- [et_pb_line_break_holder] -->  Start<!-- [et_pb_line_break_holder] --><\/a>[\/et_pb_code][\/et_pb_column][et_pb_column type=&#8221;1_2&#8243; custom_padding__hover=&#8221;|||&#8221; custom_padding=&#8221;|||&#8221;][et_pb_image _builder_version=&#8221;4.18.0&#8243; src=&#8221;https:\/\/www.phidgets.com\/education\/wp-content\/uploads\/2022\/08\/true_false_title.jpg&#8221; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243; background_pattern_color=&#8221;rgba(0,0,0,0.2)&#8221; background_mask_color=&#8221;#ffffff&#8221; \/][\/et_pb_column][\/et_pb_row][\/et_pb_section][et_pb_section bb_built=&#8221;1&#8243; specialty=&#8221;on&#8221; _builder_version=&#8221;4.4.1&#8243; use_custom_gutter=&#8221;on&#8221; gutter_width=&#8221;3&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243; prev_background_color=&#8221;#000000&#8243;][et_pb_column type=&#8221;1_4&#8243;][et_pb_code admin_label=&#8221;ph-vertical-nav&#8221; _builder_version=&#8221;4.6.6&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243; saved_tabs=&#8221;all&#8221;]<\/p>\n<div class=\"ph-vertical-nav ph-vertical-sticky\"><!-- [et_pb_line_break_holder] -->  <a href=\"#setup\" class=\"ph-vertical-nav-item\">Setup<\/a><!-- [et_pb_line_break_holder] -->  <a href=\"#write-code\" class=\"ph-vertical-nav-item\">Write code<\/a><!-- [et_pb_line_break_holder] -->  <a href=\"#practice\" class=\"ph-vertical-nav-item\">Practice<\/a><!-- [et_pb_line_break_holder] --><\/div>\n<p>[\/et_pb_code][\/et_pb_column][et_pb_column type=&#8221;3_4&#8243; specialty_columns=&#8221;3&#8243;][et_pb_row_inner _builder_version=&#8221;4.4.1&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243; module_id=&#8221;setup&#8221;][et_pb_column_inner type=&#8221;4_4&#8243; saved_specialty_column_type=&#8221;3_4&#8243; custom_padding__hover=&#8221;|||&#8221; custom_padding=&#8221;|||&#8221; saved_specialty_column_type=&#8221;3_4&#8243;][et_pb_code admin_label=&#8221;Setup&#8221; _builder_version=&#8221;4.6.6&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243; module_id=&#8221;setup&#8221;]<\/p>\n<h2>Setup<\/h2>\n<p><!-- [et_pb_line_break_holder] --><pee>All you need for this project is the Getting Started Kit.<\/strong><\/pee>[\/et_pb_code][\/et_pb_column_inner][\/et_pb_row_inner][et_pb_row_inner _builder_version=&#8221;4.4.1&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243; custom_padding=&#8221;||0px|&#8221;][et_pb_column_inner type=&#8221;1_3&#8243; saved_specialty_column_type=&#8221;3_4&#8243; custom_padding__hover=&#8221;|||&#8221; custom_padding=&#8221;|||&#8221; saved_specialty_column_type=&#8221;3_4&#8243;][et_pb_code admin_label=&#8221;Part: GSK&#8221; _builder_version=&#8221;4.18.0&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243; saved_tabs=&#8221;all&#8221; background_pattern_color=&#8221;rgba(0,0,0,0.2)&#8221; background_mask_color=&#8221;#ffffff&#8221; global_module=&#8221;8489&#8243;]<\/p>\n<div class=\"ph-part-card\"><!-- [et_pb_line_break_holder] -->  <\/p>\n<div class=\"ph-part-card__top\"><!-- [et_pb_line_break_holder] -->    <\/p>\n<div class=\"ph-part-card__type\"><!-- [et_pb_line_break_holder] -->      <\/p>\n<div class=\"ph-overline-text\"><!-- [et_pb_line_break_holder] -->        <a href=\"\">Kit\/<\/a><!-- [et_pb_line_break_holder] -->        <a href=\"\">Getting Started Kit<\/a><!-- [et_pb_line_break_holder] -->      <\/div>\n<p><!-- [et_pb_line_break_holder] -->    <\/div>\n<p><!-- [et_pb_line_break_holder] -->    <\/p>\n<div class=\"ph-part-card__title\"><!-- [et_pb_line_break_holder] -->      <\/p>\n<h3>Getting Started Kit<\/h3>\n<p><!-- [et_pb_line_break_holder] -->    <\/div>\n<p><!-- [et_pb_line_break_holder] -->  <\/div>\n<p><!-- [et_pb_line_break_holder] -->  <\/p>\n<div class=\"ph-part-card__bottom\"><!-- [et_pb_line_break_holder] -->    <img decoding=\"async\" src=\"\/education\/wp-content\/uploads\/2022\/08\/KIT4003_2_Square.jpg\" ><!-- [et_pb_line_break_holder] -->  <\/div>\n<p><!-- [et_pb_line_break_holder] --><\/div>\n<p>[\/et_pb_code][\/et_pb_column_inner][et_pb_column_inner type=&#8221;1_3&#8243; saved_specialty_column_type=&#8221;3_4&#8243; custom_padding__hover=&#8221;|||&#8221; custom_padding=&#8221;|||&#8221; saved_specialty_column_type=&#8221;3_4&#8243;][\/et_pb_column_inner][et_pb_column_inner type=&#8221;1_3&#8243; saved_specialty_column_type=&#8221;3_4&#8243; custom_padding__hover=&#8221;|||&#8221; custom_padding=&#8221;|||&#8221; saved_specialty_column_type=&#8221;3_4&#8243;][\/et_pb_column_inner][\/et_pb_row_inner][et_pb_row_inner _builder_version=&#8221;4.4.1&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243; custom_padding=&#8221;||0px|&#8221;][et_pb_column_inner type=&#8221;1_3&#8243; saved_specialty_column_type=&#8221;3_4&#8243; custom_padding__hover=&#8221;|||&#8221; custom_padding=&#8221;|||&#8221; saved_specialty_column_type=&#8221;3_4&#8243;][\/et_pb_column_inner][et_pb_column_inner type=&#8221;1_3&#8243; saved_specialty_column_type=&#8221;3_4&#8243; custom_padding__hover=&#8221;|||&#8221; custom_padding=&#8221;|||&#8221; saved_specialty_column_type=&#8221;3_4&#8243;][\/et_pb_column_inner][et_pb_column_inner type=&#8221;1_3&#8243; saved_specialty_column_type=&#8221;3_4&#8243; custom_padding__hover=&#8221;|||&#8221; custom_padding=&#8221;|||&#8221; saved_specialty_column_type=&#8221;3_4&#8243;][\/et_pb_column_inner][\/et_pb_row_inner][et_pb_row_inner admin_label=&#8221;Row&#8221; _builder_version=&#8221;4.6.6&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; disabled=&#8221;on&#8221; disabled_on=&#8221;on|on|on&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243;][et_pb_column_inner type=&#8221;1_2&#8243; saved_specialty_column_type=&#8221;3_4&#8243; custom_padding__hover=&#8221;|||&#8221; custom_padding=&#8221;|||&#8221; saved_specialty_column_type=&#8221;3_4&#8243;][et_pb_code admin_label=&#8221;Step 1&#8243; _builder_version=&#8221;4.6.6&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243;]<\/p>\n<h3>Step 1<\/h3>\n<p><!-- [et_pb_line_break_holder] --><pee>Attach the RFID Phidget to your computer.<\/pee>[\/et_pb_code][\/et_pb_column_inner][et_pb_column_inner type=&#8221;1_2&#8243; saved_specialty_column_type=&#8221;3_4&#8243; custom_padding__hover=&#8221;|||&#8221; custom_padding=&#8221;|||&#8221; saved_specialty_column_type=&#8221;3_4&#8243;][et_pb_image _builder_version=&#8221;4.6.6&#8243; src=&#8221;https:\/\/www.phidgets.com\/education\/wp-content\/uploads\/2021\/02\/rfid_connect.jpg&#8221; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243; show_in_lightbox=&#8221;on&#8221; \/][\/et_pb_column_inner][\/et_pb_row_inner][et_pb_row_inner admin_label=&#8221;Row&#8221; disabled_on=&#8221;on|on|on&#8221; disabled=&#8221;on&#8221;][et_pb_column_inner type=&#8221;4_4&#8243; saved_specialty_column_type=&#8221;3_4&#8243; custom_padding__hover=&#8221;|||&#8221; custom_padding=&#8221;|||&#8221; saved_specialty_column_type=&#8221;3_4&#8243;][et_pb_code admin_label=&#8221; (invisible anchor)&#8221; _builder_version=&#8221;4.4.1&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; module_id=&#8221;move&#8221; module_class=&#8221;ph-hidden-anchor&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243; \/][\/et_pb_column_inner][\/et_pb_row_inner][et_pb_row_inner _builder_version=&#8221;4.6.6&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; module_class=&#8221;ph-user-java&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243; module_id=&#8221;write-code&#8221;][et_pb_column_inner type=&#8221;4_4&#8243; saved_specialty_column_type=&#8221;3_4&#8243; custom_padding__hover=&#8221;|||&#8221; custom_padding=&#8221;|||&#8221; saved_specialty_column_type=&#8221;3_4&#8243;][et_pb_code admin_label=&#8221;Write code Java&#8221; _builder_version=&#8221;4.6.6&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243;]<\/p>\n<h2>Write code (Java)<\/h2>\n<p><!-- [et_pb_line_break_holder] --><pee>Copy the code below into a new Java project. If you need a reminder of how to do this, revisit the <a href=\"\/education\/learn\/getting-started-kit-tutorial\/configure-ide\">Getting Started Course.<\/a><!\u2013- [et_pb_br_holder] -\u2013><!\u2013- [et_pb_br_holder] -\u2013><!-- [et_pb_line_break_holder] -->Not your programming language? <a class=\"ph-toggle-settings\">Set your preferences<\/a> so we can display relevant code examples<\/pee>[\/et_pb_code][et_pb_code admin_label=&#8221;Code Sample &#8211; Eclipse&#8221; _builder_version=&#8221;4.6.6&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243; module_class=&#8221;ph-user-eclipse&#8221;]<!-- True or False --><!-- [et_pb_line_break_holder] --><\/p>\n<pre class=\"language-java\"><!-- [et_pb_line_break_holder] -->  <code><!-- [et_pb_line_break_holder] -->import com.phidget22.*;<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->public class True {<!-- [et_pb_line_break_holder] -->    public static void main(String[] args) throws Exception{<!-- [et_pb_line_break_holder] -->        \/\/Create <!-- [et_pb_line_break_holder] -->        DigitalInput redButton = new DigitalInput();<!-- [et_pb_line_break_holder] -->        DigitalInput greenButton = new DigitalInput();<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->        \/\/Address <!-- [et_pb_line_break_holder] -->        redButton.setHubPort(0);<!-- [et_pb_line_break_holder] -->        redButton.setIsHubPortDevice(true);<!-- [et_pb_line_break_holder] -->        greenButton.setHubPort(5);<!-- [et_pb_line_break_holder] -->        greenButton.setIsHubPortDevice(true);<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->        \/\/Open <!-- [et_pb_line_break_holder] -->        redButton.open(1000);<!-- [et_pb_line_break_holder] -->        greenButton.open(1000);<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->        \/\/Questions\/answers<!-- [et_pb_line_break_holder] -->        String[] questions = {\"2 + 2 = 4\",\"9 + 6 = 16\"};<!-- [et_pb_line_break_holder] -->        boolean[] answers = {true, false};<!-- [et_pb_line_break_holder] -->        <!-- [et_pb_line_break_holder] -->        \/\/Work through questions one by one<!-- [et_pb_line_break_holder] -->        for(int i = 0; i < questions.length; i++){<!-- [et_pb_line_break_holder] -->            System.out.println(questions[i]);<!-- [et_pb_line_break_holder] -->            \/\/tells the while loop when to stop polling buttons<!-- [et_pb_line_break_holder] -->            boolean answered = false;<!-- [et_pb_line_break_holder] -->            <!-- [et_pb_line_break_holder] -->            while(!answered){<!-- [et_pb_line_break_holder] -->                if(redButton.getState()){<!-- [et_pb_line_break_holder] -->                    if(answers[i] == false){ \/\/red is always false<!-- [et_pb_line_break_holder] -->                        System.out.println(\"Correct\");<!-- [et_pb_line_break_holder] -->                    }<!-- [et_pb_line_break_holder] -->                    else{<!-- [et_pb_line_break_holder] -->                        System.out.println(\"Incorrect\");<!-- [et_pb_line_break_holder] -->                    }<!-- [et_pb_line_break_holder] -->                    answered = true;<!-- [et_pb_line_break_holder] -->                }<!-- [et_pb_line_break_holder] -->                else if(greenButton.getState()){ \/\/green is always true<!-- [et_pb_line_break_holder] -->                    if(answers[i] == true){<!-- [et_pb_line_break_holder] -->                        System.out.println(\"Correct\");<!-- [et_pb_line_break_holder] -->                    }<!-- [et_pb_line_break_holder] -->                    else{<!-- [et_pb_line_break_holder] -->                        System.out.println(\"Incorrect\");<!-- [et_pb_line_break_holder] -->                    }<!-- [et_pb_line_break_holder] -->                    answered = true;<!-- [et_pb_line_break_holder] -->                }<!-- [et_pb_line_break_holder] -->                <!-- [et_pb_line_break_holder] -->                Thread.sleep(150);<!-- [et_pb_line_break_holder] -->            }<!-- [et_pb_line_break_holder] -->        }<!-- [et_pb_line_break_holder] -->    }<!-- [et_pb_line_break_holder] -->}<!-- [et_pb_line_break_holder] -->  <\/code><!-- [et_pb_line_break_holder] --><\/pre>\n<p>[\/et_pb_code][et_pb_code admin_label=&#8221;Code Sample &#8211; Netbeans&#8221; _builder_version=&#8221;4.6.6&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243; module_class=&#8221;ph-user-netbeans&#8221;]<!-- True or False--><!-- [et_pb_line_break_holder] --><\/p>\n<pre class=\"language-java\"><!-- [et_pb_line_break_holder] -->  <code><!-- [et_pb_line_break_holder] -->package pkgtrue;<!-- [et_pb_line_break_holder] -->import com.phidget22.*;<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->public class True {<!-- [et_pb_line_break_holder] -->    public static void main(String[] args) throws Exception{<!-- [et_pb_line_break_holder] -->        \/\/Create <!-- [et_pb_line_break_holder] -->        DigitalInput redButton = new DigitalInput();<!-- [et_pb_line_break_holder] -->        DigitalInput greenButton = new DigitalInput();<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->        \/\/Address <!-- [et_pb_line_break_holder] -->        redButton.setHubPort(0);<!-- [et_pb_line_break_holder] -->        redButton.setIsHubPortDevice(true);<!-- [et_pb_line_break_holder] -->        greenButton.setHubPort(5);<!-- [et_pb_line_break_holder] -->        greenButton.setIsHubPortDevice(true);<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->        \/\/Open <!-- [et_pb_line_break_holder] -->        redButton.open(1000);<!-- [et_pb_line_break_holder] -->        greenButton.open(1000);<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->        \/\/Questions\/answers<!-- [et_pb_line_break_holder] -->        String[] questions = {\"2 + 2 = 4\",\"9 + 6 = 16\"};<!-- [et_pb_line_break_holder] -->        boolean[] answers = {true, false};<!-- [et_pb_line_break_holder] -->        <!-- [et_pb_line_break_holder] -->        \/\/Work through questions one by one<!-- [et_pb_line_break_holder] -->        for(int i = 0; i < questions.length; i++){<!-- [et_pb_line_break_holder] -->            System.out.println(questions[i]);<!-- [et_pb_line_break_holder] -->            \/\/tells the while loop when to stop polling buttons<!-- [et_pb_line_break_holder] -->            boolean answered = false;<!-- [et_pb_line_break_holder] -->            <!-- [et_pb_line_break_holder] -->            while(!answered){<!-- [et_pb_line_break_holder] -->                if(redButton.getState()){<!-- [et_pb_line_break_holder] -->                    if(answers[i] == false){ \/\/red is always false<!-- [et_pb_line_break_holder] -->                        System.out.println(\"Correct\");<!-- [et_pb_line_break_holder] -->                    }<!-- [et_pb_line_break_holder] -->                    else{<!-- [et_pb_line_break_holder] -->                        System.out.println(\"Incorrect\");<!-- [et_pb_line_break_holder] -->                    }<!-- [et_pb_line_break_holder] -->                    answered = true;<!-- [et_pb_line_break_holder] -->                }<!-- [et_pb_line_break_holder] -->                else if(greenButton.getState()){ \/\/green is always true<!-- [et_pb_line_break_holder] -->                    if(answers[i] == true){<!-- [et_pb_line_break_holder] -->                        System.out.println(\"Correct\");<!-- [et_pb_line_break_holder] -->                    }<!-- [et_pb_line_break_holder] -->                    else{<!-- [et_pb_line_break_holder] -->                        System.out.println(\"Incorrect\");<!-- [et_pb_line_break_holder] -->                    }<!-- [et_pb_line_break_holder] -->                    answered = true;<!-- [et_pb_line_break_holder] -->                }<!-- [et_pb_line_break_holder] -->                <!-- [et_pb_line_break_holder] -->                Thread.sleep(150);<!-- [et_pb_line_break_holder] -->            }<!-- [et_pb_line_break_holder] -->        }<!-- [et_pb_line_break_holder] -->    }<!-- [et_pb_line_break_holder] -->}<!-- [et_pb_line_break_holder] -->  <\/code><!-- [et_pb_line_break_holder] --><\/pre>\n<p>[\/et_pb_code][et_pb_code admin_label=&#8221;Code Sample &#8211; Processing&#8221; _builder_version=&#8221;4.6.6&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243; module_class=&#8221;ph-user-processing&#8221;]<!-- True or False--><!-- [et_pb_line_break_holder] --><\/p>\n<pre class=\"language-java\"><!-- [et_pb_line_break_holder] -->  <code><!-- [et_pb_line_break_holder] -->\/\/Add Phidgets Library<!-- [et_pb_line_break_holder] -->import com.phidget22.*;<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->\/\/Define<!-- [et_pb_line_break_holder] -->DigitalInput redButton;<!-- [et_pb_line_break_holder] -->DigitalInput greenButton;<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->\/\/Questions\/answers<!-- [et_pb_line_break_holder] -->String[] questions = {\"2 + 2 = 4\\n\",\"9 + 6 = 16\\n\"};<!-- [et_pb_line_break_holder] -->boolean[] answers = {true, false};<!-- [et_pb_line_break_holder] -->boolean answered = false;<!-- [et_pb_line_break_holder] -->int i = 0;<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->void setup(){<!-- [et_pb_line_break_holder] -->  try{<!-- [et_pb_line_break_holder] -->    <!-- [et_pb_line_break_holder] -->    \/\/Create<!-- [et_pb_line_break_holder] -->    redButton = new DigitalInput();<!-- [et_pb_line_break_holder] -->    greenButton = new DigitalInput();<!-- [et_pb_line_break_holder] -->    <!-- [et_pb_line_break_holder] -->    \/\/Address <!-- [et_pb_line_break_holder] -->    redButton.setHubPort(0);<!-- [et_pb_line_break_holder] -->    redButton.setIsHubPortDevice(true);<!-- [et_pb_line_break_holder] -->    greenButton.setHubPort(5);<!-- [et_pb_line_break_holder] -->    greenButton.setIsHubPortDevice(true);<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->    \/\/Open <!-- [et_pb_line_break_holder] -->    redButton.open(1000);<!-- [et_pb_line_break_holder] -->    greenButton.open(1000);<!-- [et_pb_line_break_holder] -->    <!-- [et_pb_line_break_holder] -->  }catch(Exception e){<!-- [et_pb_line_break_holder] -->    \/\/Handle Exceptions<!-- [et_pb_line_break_holder] -->    e.printStackTrace();<!-- [et_pb_line_break_holder] -->  }<!-- [et_pb_line_break_holder] -->}<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->void draw(){<!-- [et_pb_line_break_holder] -->  <!-- [et_pb_line_break_holder] -->  try{<!-- [et_pb_line_break_holder] -->    if(i < questions.length){<!-- [et_pb_line_break_holder] -->      if(i == 0 || answered){<!-- [et_pb_line_break_holder] -->         print(questions[i]);<!-- [et_pb_line_break_holder] -->         i += 1;<!-- [et_pb_line_break_holder] -->         answered = false;<!-- [et_pb_line_break_holder] -->      }<!-- [et_pb_line_break_holder] -->    }<!-- [et_pb_line_break_holder] -->    if(redButton.getState() && !answered){      <!-- [et_pb_line_break_holder] -->      if(answers[i-1] == false){<!-- [et_pb_line_break_holder] -->        print(\"Correct\\n\");<!-- [et_pb_line_break_holder] -->      }<!-- [et_pb_line_break_holder] -->      else{<!-- [et_pb_line_break_holder] -->        print(\"Incorrect\\n\");<!-- [et_pb_line_break_holder] -->      }<!-- [et_pb_line_break_holder] -->      answered = true;<!-- [et_pb_line_break_holder] -->    }<!-- [et_pb_line_break_holder] -->    else if(greenButton.getState() && !answered){<!-- [et_pb_line_break_holder] -->      if(answers[i-1] == true){<!-- [et_pb_line_break_holder] -->        print(\"Correct\\n\");<!-- [et_pb_line_break_holder] -->      }<!-- [et_pb_line_break_holder] -->      else{<!-- [et_pb_line_break_holder] -->        print(\"Incorrect\\n\");<!-- [et_pb_line_break_holder] -->      }<!-- [et_pb_line_break_holder] -->      answered = true;<!-- [et_pb_line_break_holder] -->    }    <!-- [et_pb_line_break_holder] -->    delay(150);<!-- [et_pb_line_break_holder] -->    <!-- [et_pb_line_break_holder] -->  }catch(Exception e){<!-- [et_pb_line_break_holder] -->    \/\/Handle Exceptions<!-- [et_pb_line_break_holder] -->    e.printStackTrace();<!-- [et_pb_line_break_holder] -->  }<!-- [et_pb_line_break_holder] -->}<!-- [et_pb_line_break_holder] -->  <\/code><!-- [et_pb_line_break_holder] --><\/pre>\n<p>[\/et_pb_code][\/et_pb_column_inner][\/et_pb_row_inner][et_pb_row_inner _builder_version=&#8221;4.6.6&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; module_class=&#8221;ph-user-python&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243; module_id=&#8221;write-code&#8221;][et_pb_column_inner type=&#8221;4_4&#8243; saved_specialty_column_type=&#8221;3_4&#8243; custom_padding__hover=&#8221;|||&#8221; custom_padding=&#8221;|||&#8221; saved_specialty_column_type=&#8221;3_4&#8243;][et_pb_code admin_label=&#8221;Write code Python&#8221; _builder_version=&#8221;4.6.6&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243;]<\/p>\n<h2>Write code (Python)<\/h2>\n<p><!-- [et_pb_line_break_holder] --><pee>Copy the code below into a new Python project. If you need a reminder of how to do this, revisit the <a href=\"\/education\/learn\/getting-started-kit-tutorial\/configure-ide\">Getting Started Course.<\/a><!\u2013- [et_pb_br_holder] -\u2013><!\u2013- [et_pb_br_holder] -\u2013><!-- [et_pb_line_break_holder] -->Not your programming language? <a class=\"ph-toggle-settings\">Set your preferences<\/a> so we can display relevant code examples<\/pee>[\/et_pb_code][et_pb_code admin_label=&#8221;Code Sample&#8221; _builder_version=&#8221;4.6.6&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243;]<!--True or False--><!-- [et_pb_line_break_holder] --><\/p>\n<pre class=\"language-python\"><!-- [et_pb_line_break_holder] -->  <code><!-- [et_pb_line_break_holder] -->#Add Phidgets Library<!-- [et_pb_line_break_holder] -->from Phidget22.Phidget import *<!-- [et_pb_line_break_holder] -->from Phidget22.Devices.DigitalInput import *<!-- [et_pb_line_break_holder] -->#Required for sleep statement<!-- [et_pb_line_break_holder] -->import time <!-- [et_pb_line_break_holder] --> <!-- [et_pb_line_break_holder] -->#Create<!-- [et_pb_line_break_holder] -->redButton = DigitalInput()<!-- [et_pb_line_break_holder] -->greenButton = DigitalInput()<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->#Address<!-- [et_pb_line_break_holder] -->redButton.setHubPort(0)<!-- [et_pb_line_break_holder] -->redButton.setIsHubPortDevice(True)<!-- [et_pb_line_break_holder] -->greenButton.setHubPort(5)<!-- [et_pb_line_break_holder] -->greenButton.setIsHubPortDevice(True)<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->#Open<!-- [et_pb_line_break_holder] -->redButton.openWaitForAttachment(1000)<!-- [et_pb_line_break_holder] -->greenButton.openWaitForAttachment(1000)<!-- [et_pb_line_break_holder] -->        <!-- [et_pb_line_break_holder] -->#Questions\/Answers<!-- [et_pb_line_break_holder] -->questions = [\"2 + 2 = 4\",\"9 + 6 = 16\"]<!-- [et_pb_line_break_holder] -->answers = [True, False]<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->#Work through questions one by one<!-- [et_pb_line_break_holder] -->for i in range(0, len(questions)):<!-- [et_pb_line_break_holder] -->    print(questions[i])<!-- [et_pb_line_break_holder] -->    #tells the while loop when to stop polling buttons<!-- [et_pb_line_break_holder] -->    answered = False <!-- [et_pb_line_break_holder] -->    <!-- [et_pb_line_break_holder] -->    while(not answered):    <!-- [et_pb_line_break_holder] -->        if(redButton.getState()):<!-- [et_pb_line_break_holder] -->            if(answers[i] == False): #red is always false<!-- [et_pb_line_break_holder] -->                print(\"Correct\")<!-- [et_pb_line_break_holder] -->            else:<!-- [et_pb_line_break_holder] -->                print(\"Incorrect\")<!-- [et_pb_line_break_holder] -->            answered = True            <!-- [et_pb_line_break_holder] -->        elif(greenButton.getState()):<!-- [et_pb_line_break_holder] -->            if(answers[i] == True): #green is always true<!-- [et_pb_line_break_holder] -->                print(\"Correct\")<!-- [et_pb_line_break_holder] -->            else:<!-- [et_pb_line_break_holder] -->                print(\"Incorrect\")<!-- [et_pb_line_break_holder] -->            answered = True<!-- [et_pb_line_break_holder] -->            <!-- [et_pb_line_break_holder] -->        time.sleep(0.15)<!-- [et_pb_line_break_holder] -->  <\/code><!-- [et_pb_line_break_holder] --><\/pre>\n<p>[\/et_pb_code][\/et_pb_column_inner][\/et_pb_row_inner][et_pb_row_inner _builder_version=&#8221;4.4.1&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; module_class=&#8221;ph-user-csharp&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243; module_id=&#8221;write-code&#8221;][et_pb_column_inner type=&#8221;4_4&#8243; saved_specialty_column_type=&#8221;3_4&#8243; custom_padding__hover=&#8221;|||&#8221; custom_padding=&#8221;|||&#8221; saved_specialty_column_type=&#8221;3_4&#8243;][et_pb_code admin_label=&#8221;Write code C#&#8221; _builder_version=&#8221;4.6.6&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243;]<\/p>\n<h2>Write code (C#)<\/h2>\n<p><!-- [et_pb_line_break_holder] --><pee>Copy the code below into a new C# project. If you need a reminder of how to do this, revisit the <a href=\"\/education\/learn\/getting-started-kit-tutorial\/configure-ide\">Getting Started Course.<\/a><!\u2013- [et_pb_br_holder] -\u2013><!\u2013- [et_pb_br_holder] -\u2013><!-- [et_pb_line_break_holder] -->Not your programming language? <a class=\"ph-toggle-settings\">Set your preferences<\/a> so we can display relevant code examples<\/pee>[\/et_pb_code][et_pb_code admin_label=&#8221;Code Sample&#8221; _builder_version=&#8221;4.6.6&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243;]<!-- True or False--><!-- [et_pb_line_break_holder] --><\/p>\n<pre class=\"language-csharp\"><!-- [et_pb_line_break_holder] -->  <code><!-- [et_pb_line_break_holder] -->using System;<!-- [et_pb_line_break_holder] -->using Phidget22;<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->namespace True<!-- [et_pb_line_break_holder] -->{<!-- [et_pb_line_break_holder] -->    class Program<!-- [et_pb_line_break_holder] -->    {<!-- [et_pb_line_break_holder] -->        static void Main(string[] args)<!-- [et_pb_line_break_holder] -->        {<!-- [et_pb_line_break_holder] -->            \/\/Create <!-- [et_pb_line_break_holder] -->            DigitalInput redButton = new DigitalInput();<!-- [et_pb_line_break_holder] -->            DigitalInput greenButton = new DigitalInput();<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->            \/\/Address <!-- [et_pb_line_break_holder] -->            redButton.HubPort = 0;<!-- [et_pb_line_break_holder] -->            redButton.IsHubPortDevice = true;<!-- [et_pb_line_break_holder] -->            greenButton.HubPort = 5;<!-- [et_pb_line_break_holder] -->            greenButton.IsHubPortDevice = true;<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->            \/\/Open <!-- [et_pb_line_break_holder] -->            redButton.Open(1000);<!-- [et_pb_line_break_holder] -->            greenButton.Open(1000);<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->            \/\/Questions\/answers<!-- [et_pb_line_break_holder] -->            String[] questions = { \"2 + 2 = 4\", \"9 + 6 = 16\" };<!-- [et_pb_line_break_holder] -->            bool[] answers = { true, false };<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->            \/\/Work through questions one by one<!-- [et_pb_line_break_holder] -->            for(int i = 0; i < questions.Length; i++)<!-- [et_pb_line_break_holder] -->            {<!-- [et_pb_line_break_holder] -->                Console.WriteLine(questions[i]);<!-- [et_pb_line_break_holder] -->                \/\/tells the while loop when to stop polling buttons<!-- [et_pb_line_break_holder] -->                bool answered = false;<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->                while (!answered)<!-- [et_pb_line_break_holder] -->                {<!-- [et_pb_line_break_holder] -->                    if (redButton.State)<!-- [et_pb_line_break_holder] -->                    {<!-- [et_pb_line_break_holder] -->                        if(answers[i] == false) \/\/red is always false<!-- [et_pb_line_break_holder] -->                        {<!-- [et_pb_line_break_holder] -->                            Console.WriteLine(\"Correct\");<!-- [et_pb_line_break_holder] -->                        }<!-- [et_pb_line_break_holder] -->                        else<!-- [et_pb_line_break_holder] -->                        {<!-- [et_pb_line_break_holder] -->                            Console.WriteLine(\"Incorrect\");<!-- [et_pb_line_break_holder] -->                        }<!-- [et_pb_line_break_holder] -->                        answered = true;<!-- [et_pb_line_break_holder] -->                    }<!-- [et_pb_line_break_holder] -->                    else if (greenButton.State)<!-- [et_pb_line_break_holder] -->                    {<!-- [et_pb_line_break_holder] -->                        if (answers[i] == true) \/\/green is always true<!-- [et_pb_line_break_holder] -->                        {<!-- [et_pb_line_break_holder] -->                            Console.WriteLine(\"Correct\");<!-- [et_pb_line_break_holder] -->                        }<!-- [et_pb_line_break_holder] -->                        else<!-- [et_pb_line_break_holder] -->                        {<!-- [et_pb_line_break_holder] -->                            Console.WriteLine(\"Incorrect\");<!-- [et_pb_line_break_holder] -->                        }<!-- [et_pb_line_break_holder] -->                        answered = true;<!-- [et_pb_line_break_holder] -->                    }<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->                    System.Threading.Thread.Sleep(150);<!-- [et_pb_line_break_holder] -->                }<!-- [et_pb_line_break_holder] -->            }<!-- [et_pb_line_break_holder] -->        }<!-- [et_pb_line_break_holder] -->    }<!-- [et_pb_line_break_holder] -->}<!-- [et_pb_line_break_holder] -->  <\/code><!-- [et_pb_line_break_holder] --><\/pre>\n<p>[\/et_pb_code][\/et_pb_column_inner][\/et_pb_row_inner][et_pb_row_inner _builder_version=&#8221;4.4.1&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; module_class=&#8221;ph-user-swift&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243; module_id=&#8221;write-code&#8221;][et_pb_column_inner type=&#8221;4_4&#8243; saved_specialty_column_type=&#8221;3_4&#8243; custom_padding__hover=&#8221;|||&#8221; custom_padding=&#8221;|||&#8221; saved_specialty_column_type=&#8221;3_4&#8243;][et_pb_code admin_label=&#8221;Write code Swift&#8221; _builder_version=&#8221;4.6.6&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243;]<\/p>\n<h2>Write code (Swift)<\/h2>\n<p><!-- [et_pb_line_break_holder] --><pee>Copy the code below into a new Swift project. If you need a reminder of how to do this, revisit the <a href=\"\/education\/learn\/getting-started-kit-tutorial\/configure-ide\">Getting Started Course.<\/a><!\u2013- [et_pb_br_holder] -\u2013><!\u2013- [et_pb_br_holder] -\u2013><!-- [et_pb_line_break_holder] -->Not your programming language? <a class=\"ph-toggle-settings\">Set your preferences<\/a> so we can display relevant code examples<\/pee>[\/et_pb_code][et_pb_code admin_label=&#8221;Code Sample&#8221; _builder_version=&#8221;4.6.6&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243;]<!-- Sound Level Meter --><!-- [et_pb_line_break_holder] --><\/p>\n<pre class=\"language-swift\"><!-- [et_pb_line_break_holder] -->  <code><!-- [et_pb_line_break_holder] -->Coming Soon!<!-- [et_pb_line_break_holder] -->  <\/code><!-- [et_pb_line_break_holder] --><\/pre>\n<p>[\/et_pb_code][\/et_pb_column_inner][\/et_pb_row_inner][et_pb_row_inner _builder_version=&#8221;4.4.1&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243;][et_pb_column_inner type=&#8221;4_4&#8243; saved_specialty_column_type=&#8221;3_4&#8243; custom_padding__hover=&#8221;|||&#8221; custom_padding=&#8221;|||&#8221; saved_specialty_column_type=&#8221;3_4&#8243;][et_pb_code admin_label=&#8221;Instructions&#8221; _builder_version=&#8221;4.6.6&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243;]<pee>Run your program. You will see a question printed to your screen. Use the green button to answer true and the red button to answer false.<\/pee>[\/et_pb_code][\/et_pb_column_inner][\/et_pb_row_inner][et_pb_row_inner _builder_version=&#8221;4.4.1&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243; module_id=&#8221;practice&#8221;][et_pb_column_inner type=&#8221;4_4&#8243; saved_specialty_column_type=&#8221;3_4&#8243; custom_padding__hover=&#8221;|||&#8221; custom_padding=&#8221;|||&#8221; saved_specialty_column_type=&#8221;3_4&#8243;][et_pb_code admin_label=&#8221;Practice&#8221; _builder_version=&#8221;4.6.6&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243;]<\/p>\n<h2>Practice<\/h2>\n<p><!-- [et_pb_line_break_holder] --><\/p>\n<ol><!-- [et_pb_line_break_holder] --><\/p>\n<li>Using a notepad or word processor, explain how the code above works.<\/li>\n<p><!-- [et_pb_line_break_holder] --><\/p>\n<li>Modify the code so there is a total of 10 questions.<\/li>\n<p><!-- [et_pb_line_break_holder] --><\/p>\n<li>Log the users score as they progress through the list of questions. At the end of the game, display the total score.<\/li>\n<p><!-- [et_pb_line_break_holder] --><\/p>\n<li>Use <a href=\"\/education\/learn\/getting-started-kit-tutorial\/dataevents_1\/\" target=\"_blank\" rel=\"noopener noreferrer\">button events<\/a> instead of polling to improve the functionality of your game.<\/li>\n<p><!-- [et_pb_line_break_holder] --><\/ol>\n<p>[\/et_pb_code][\/et_pb_column_inner][\/et_pb_row_inner][et_pb_row_inner admin_label=&#8221;Row&#8221;][et_pb_column_inner type=&#8221;4_4&#8243; saved_specialty_column_type=&#8221;3_4&#8243; custom_padding__hover=&#8221;|||&#8221; custom_padding=&#8221;|||&#8221; saved_specialty_column_type=&#8221;3_4&#8243;][et_pb_code admin_label=&#8221;ph-button-cta: Back to Projects&#8221; _builder_version=&#8221;4.4.1&#8243; box_shadow_horizontal_tablet=&#8221;0px&#8221; box_shadow_vertical_tablet=&#8221;0px&#8221; box_shadow_blur_tablet=&#8221;40px&#8221; box_shadow_spread_tablet=&#8221;0px&#8221; vertical_offset_tablet=&#8221;0&#8243; horizontal_offset_tablet=&#8221;0&#8243; z_index_tablet=&#8221;0&#8243;]<a class=\"ph-button-cta\" href=\"\/education\/learn\/projects\"><!-- [et_pb_line_break_holder] -->  <\/p>\n<div class=\"ph-button-cta__icon\"><\/div>\n<p><!-- [et_pb_line_break_holder] -->  Back to Projects<!-- [et_pb_line_break_holder] --><\/a>[\/et_pb_code][\/et_pb_column_inner][\/et_pb_row_inner][\/et_pb_column][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>import com.phidget22.*;public class True { public static void main(String[] args) throws Exception{ \/\/Create DigitalInput redButton = new DigitalInput(); DigitalInput greenButton = new DigitalInput(); \/\/Address redButton.setHubPort(0); redButton.setIsHubPortDevice(true); greenButton.setHubPort(5); greenButton.setIsHubPortDevice(true); \/\/Open redButton.open(1000); greenButton.open(1000); \/\/Questions\/answers String[] questions = {&#8220;2 + 2 = 4&#8243;,&#8221;9 + 6 = 16&#8221;}; boolean[] answers = {true, false}; \/\/Work through questions one by one [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"parent":842,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"<!-- wp:paragraph -->\r\n<p>This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:<\/p>\r\n<!-- \/wp:paragraph --><!-- wp:quote -->\r\n<blockquote class=\"wp-block-quote\">\r\n<p>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like pi\u00f1a coladas. (And gettin' caught in the rain.)<\/p>\r\n<\/blockquote>\r\n<!-- \/wp:quote --><!-- wp:paragraph -->\r\n<p>...or something like this:<\/p>\r\n<!-- \/wp:paragraph --><!-- wp:quote -->\r\n<blockquote class=\"wp-block-quote\">\r\n<p>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.<\/p>\r\n<\/blockquote>\r\n<!-- \/wp:quote --><!-- wp:paragraph -->\r\n<p>As a new WordPress user, you should go to <a href=\"https:\/\/www.phidgets.com\/education\/wp-admin\/\">your dashboard<\/a> to delete this page and create new pages for your content. Have fun!<\/p>\r\n<!-- \/wp:paragraph -->","_et_gb_content_width":"","footnotes":""},"class_list":["post-4499","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.phidgets.com\/education\/wp-json\/wp\/v2\/pages\/4499","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.phidgets.com\/education\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.phidgets.com\/education\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.phidgets.com\/education\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.phidgets.com\/education\/wp-json\/wp\/v2\/comments?post=4499"}],"version-history":[{"count":10,"href":"https:\/\/www.phidgets.com\/education\/wp-json\/wp\/v2\/pages\/4499\/revisions"}],"predecessor-version":[{"id":8527,"href":"https:\/\/www.phidgets.com\/education\/wp-json\/wp\/v2\/pages\/4499\/revisions\/8527"}],"up":[{"embeddable":true,"href":"https:\/\/www.phidgets.com\/education\/wp-json\/wp\/v2\/pages\/842"}],"wp:attachment":[{"href":"https:\/\/www.phidgets.com\/education\/wp-json\/wp\/v2\/media?parent=4499"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}