Write My Paper Button

WhatsApp Widget

ENEX 20001 2025 T1 Assignment 2 C Language Programming

ENEX 20001 2025 T1

Assignment 2 C Language Programming

Due date:

Week 5, Friday (11th April 2025) 23:45

20% of the unit final mark 30%

Online Moodle (See the submission instructions below)

Weighting:

Minimum:

Submission

1

Important Note:

It is important to note that this assignment is intended to be completed individually, and sharing your code with others is strictly prohibited. If you use any external resources including tutorial sample codes, please ensure that you provide clear references in the comments to avoid plagiarism. CQUniversity places a high value on academic honesty and integrity, and any breach of these standards may result in severe penalties. If you require additional guidance on academic integrity, please refer to the information provided in the following link.

https://cqunilife.com/2020/01/07/do-you-understand-academic-integrity/

You can only use c programming libraries and functions introduced in week 1-4 lectures and you cannot use any other library or functions to complete the assignment. If you are not sure then clarify it with the unit coordinator.

You cannot use any of the Arduino Functions (https://www.arduino.cc/reference/en/) in all the assessments in this unit. Zero marks will be given if you use any Arduino functions or codes.

(100% of marks is equal to 25% of the unit total)

To submit the assignment:

  1. Create a Single PDF file with your answers for each question and submit it to the Moodle site. Follow the assessment criteria and instructions when answering each question.

  1. Create a PDF file with your code for each question and upload it to the Moodle Name the PDF files Q1-code.pdf, Q2-code.pdf. Copy the AVR C program files from the Tinkercad to Word file and create PDF files. Any submitted program with compilation errors will receive very low marks.

  1. Download the C program files from the Tinckercad simulation and make a zip Name the zip file as codes. Zip and upload it to Moodle.

  1. Upload a separate video file for each question that demonstrates your working program to Moodle. The maximum file size is 100MB. Name the video files Q1-video, Q2-video, and Q3- video. The demonstration should include verbal explanations and show your face. If not you will receive zero marks.

  1. The simulation and required AVR C programming should be done in the class Tinckercad simulation You will get a separate workspace for assignment 1 and it shouldnt be modified after the final submission. Any modifications after the final submission will result in zero marks.

Q1.

  1. Add 103 (decimal) to the last two digits of your student number and convert it to a binary number of 8 bits. You have to manually calculate the binary conversion and show the steps in your report. You must get this conversion right and otherwise answers to all the following sections will be wrong. Verify your conversion using a calculator or an online conversion table. (5 marks)
  1. Write down all the steps in your report to convert the binary number created earlier to 01010101 only using bit set and clear operations only ( SHIFT, AND, OR and NOT operations). In each step, only one bit should be changed. You need to show in each step, how bits are changed in each binary operation. (10 marks)
  1. Write a C code in your report to do the conversion in questions b.) starting from the last two digits of your student number ( store it as a variable). You can only store the last two digits of your student number in a variable and all other operations need to be done using standard C code. Add comments to explain your code.

(5 marks)

4. Wire the Arduino Uno board in the Tinker Cad class assignment space to display 8-bit binary numbers using 8 LEDs. Use the pins, as assigned according to the following table based on the binary number created in question (Q1.a.). All LEDs need to be labelled according to the following table. Include a screenshot of the Tinkercad breadboard and the circuit diagram in your report. See the following example, for binary number 01100101, and you must include a similar table in your report for your binary number created in Q1.a and choose the microcontroller pins accordingly. (10 marks)

*The following table is an example only, find the pins to which each LED need to be connected based on your student number.

LED Label

LED7

LED6

LED5

LED4

LED3

LED2

LED1

LED0

Bit Number

7

6

5

4

3

2

1

0

The binary number from Question 1. A

(This is an example only)

0

1

1

0

0

1

0

1

Port Pins Each LED is connected

All zero bits should be assigned to the corresponding PORTD pins

All one bits need to be assigned to the corresponding PORTB pin for LED0 -LED5, ). If

there are 1s in

bits 6 and 7 then use PC4 and PC5.

PD7

PC4

PB5

PD4

PD3

PB2

PD1

PB0

5. Write a C code in Tinckercad to display the number created in Q1.a and Q1.b alternatively with a 1-second interval in LED0 should display the 0th bit and LED7 should display the 7th bit and each bit should match all other LED labels. Your program should be properly commented on and should work in the simulation. You need to complete the following activities to complete this assessment item. (20 marks)

  • C codes for Q1. a and Q1.b need to be included in the main program. Optimise the code to use the least number of code lines.
  • Add a screenshot of the code to the report and explain the
  • A clear video recording from the simulation needs to be uploaded to the Moodle site as evidence of the correct functionality of the code. The video demo should include a clear verbal explanation of the code and your face should be visible in the video. ( use third-party software or Zoom screen recording)
  • The Tinckercad simulation files should not be modified after the due date of the assignment. The last edited time should be before the submission date and zero marks will be given if the files were modified after the submission

Q2.

In this question, you will build a simulated robot using the TinkerCad simulator. The robot will have two gear motors connected to two wheels and 2 tactile sensors (SL, and SR) simulated as pushbuttons. You are only required to simulate the electronic circuit with motors and push buttons and write a C program to control the Arduino Uno board. You need to have L293D motor controller circuit to control the two motors.

The SL and SR sensors will be used to detect any obstacles and it is simulated as push buttons presses. In the Tinkercad simulation, use push buttons to simulate the tactile sensors. You are required to write an AVR C program to control the robot and show its functionality using the simulation by showing the motors are rotating in the correct direction. The robot should behave as follows.

  • When there is an obstacle in the right direction but not in the left direction then the robot should move to the left side.
  • When there is an obstacle in the left direction but not in the right direction then the robot should move to the right side.
  • When there is a larger obstacle at the front which is detected by both sensors then the robot should reverse.
  • In all other cases, the robot moves forward

Each student should choose the pins of the microcontroller uno board to interface L293 based on the following table.

*The following table is an example only, find the pins to which each L293D control pins need to be connected based on your student number.

ENEX 20001 2025 T1 Assignment 2 C Language Programming
Scroll to top

Get 40% off! ✨ Instant Help from Our Experts Awaits! Don’t miss out! 💡

X