Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:iot-open:remotelab:sut:generalpurpose2:b1 [2019/07/24 19:54] pczekalskien:iot-open:remotelab:sut:generalpurpose2:b1 [2020/10/25 10:00] (current) – external edit 127.0.0.1
Line 1: Line 1:
-==== Basic operations on the 4x20 LCD screen ==== +==== B1: Basic operations on the 4x20 LCD screen ==== 
-//Give few words about this scenario. Provide some objectives and impact on the students.//+Whatever you do, you expect to have some output of the system. Sometimes there is a blinking LED, sometimes information about connected/disconnected network and some other time simply trace algorithm progress. In laboratories where you have physically connected MCU to your programming device (i.e. computer), you usually would choose ''Serial'' port to report about what is going on. However here all you have is access via the video streamPerhaps those are reasons you will use this LCD display in your every lab work. 
 + 
 +<note important>Note, the video stream from the camera is limited in bandwidth and presents some 5-10fps maximum (usually around 1 fps) so you shouldn't change display content nor LED state faster than once every 2 seconds, to let you notice any change!</note> 
 === Target group === === Target group ===
-//This hands-on lab guide is intended for the Beginners/Undergraduates/Masters/Professionals. Choose appropriate.//+This hands-on lab guide is intended for the Beginners but other target groups may benefit from it, treating it as a tool for advanced projects.
  
 === Prerequisites === === Prerequisites ===
-//Provide prerequisite readings/hardware/software/software libraries/skills if other than stated in the Laboratory DescriptionIf noneremove along with the headerPlease note some of those may be common for all scenarios (i.emqtt library), so provide it in the laboratory description levelnot in the scenario level.//+There are no other prerequisites than LCD I2C libraryMindLCD is controlled via the I2C busLCD Display is 4×20 charactersLCD is controlled via I2C extender: LCM1602The I2C extender address is 0x3F or 0x27 (depends on the laboratory nodeplease refer to the documentation!) and the I2C bus is connected to the pins D1 and D2 (D1 is SCL and D2 is SDA). 
 + 
 +<note important>There are two types of I2C extenders differing their I2C address: 
 +  * Nodes 1 through 5, 8 and 9 use 0x3F 
 +  * Nodes 10 and 11 use 0x27 
 +</note>
  
 === Scenario === === Scenario ===
-//Describe scenario to let the user understand its idea and process. Write information about the approachalgorithm, etc. (depends on the lab)Provide useful information about protocolsassumptions, addresses (i.e. communication servers), credentialsetc.//+Initialize LCD screen, clear it then write some fancy text on it, i.e. "Hello IOT!" in the first line then your first name in the second line and the name of the city you're inin the thirdIn the fourth lineprint right-aligned number of ''loop'' iterations (delay it for 1 second between updates - to observe video stream lag and delays). Notedelays are provided in msnot in s.
  
 === Result === === Result ===
-//Describe expected result when scenario is finished.//+You should see the texts and ticking counter in the video stream.
  
 === Start === === Start ===
-//Write starting conditions, i.e. what to do at the beginning, what to pay attention before beginning, how the mechanical part should look like,  etc.//+There are no special steps to be performed.
  
 === Steps === === Steps ===
-// Write some extra information if i.e. some steps are optional otherwise cancel this paragraph (but do not remove header).// 
-== Step 1 == 
-//Describe activities done in Step 1.// 
  
 +== Step 1 ==
 +Include LCD driver library:
 +<code c>
 +#include <LiquidCrystal_I2C.h>
 +</code>
 +== Step 2 ==
 +Instantiate software controler component for the LCD display:
 +<code c>
 +LiquidCrystal_I2C lcd(0x3F,20,4);  // set the LCD address to 0x3F for nodes 1 through 5, 8 and 9
 +//LiquidCrystal_I2C lcd(0x27,20,4); //for nodes 10 and 11 only!
 +                                   // for a 20 chars and 4 line display
 +</code>
 +== Step 3 ==
 +Declare some variables: counter ''i'', its length ''n'' and ''buffer'' for the into to string conversion:
 +<code c>
 +int i = 0;
 +char buffer [50];
 +int n;
 +</code>
 +We will use them in further part of the code.
 +== Step 3 ==
 +Initialize display - we suggest to do it in ''setup()'' function:
 +<code c>
 ... ...
- +  lcd.init(D2,D1);                 // initialize the lcd I2C 
-== Step == +  lcd.backlight();                 // switch on the backlight 
-//Describe activities done in Step n.//+... 
 +</code> 
 +== Step == 
 +Clear the contents, set cursor and draw static text - still in ''setup()'' function: 
 +<code c> 
 +... 
 +  lcd.home(); 
 +  lcd.print("Hello IOT!"); 
 +  lcd.setCursor(0, 1); 
 +  lcd.print("James Bond here"); 
 +  lcd.setCursor(0,2); 
 +  lcd.print("London"); 
 +... 
 +</code> 
 +== Step 5 == 
 +Implement ''loop()'' to draw number of loop executions: 
 +<code c> 
 +... 
 +  i++; 
 +  n=sprintf(buffer,"%d",i); 
 +  lcd.setCursor(20-n,3); 
 +  lcd.print(i); 
 +  delay(1000); 
 +... 
 +</code> 
 +<note tip>''sprintf'' uses number of wildcards that are rendered with data. Refer to the c/c++ documentation on ''sprintf''. Here ''%d'' means: having integer number render it to string and as we do not specify number of digits, it is up to the engine to convert it properly.\\''delay(time)'' is measured in milliseconds.</note>
  
 === Result validation === === Result validation ===
-//Provide some result validation methodsfor self assesment.//+Observe textits position and counter ticking in lower, right corner.
  
-=== FAQ === 
-This section is to be extended as new questions appear. \\ 
-When using the printed version of this manual please refer to the latest online version of this document to obtain the valid and up-to-date list of the FAQ. 
-//Provide some FAQs in the following form:\\ 
-**Question?**: Answer. 
-// 
  
en/iot-open/remotelab/sut/generalpurpose2/b1.1563998093.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0