CubeSats relying solely on small microcontroller have very limited computational resources, which restricts any usage of sophisticated control algorithms. Most existing attitude control algorithms require full state information such as attitude information in terms of quaternion, angular rate and a desired target direction. UKube-1 is a CubeSat commissioned by the UK Space Agency and integrated by Clyde Space Ltd. in Glasgow, UK. It has various payloads and requires to produce a certain level of power using the solar panels. Hence, it needs to search for the sun direction and keep the desired attitude while the sun is visible to the satellite. A sun tracking algorithm is developed, which uses the information from the coarse sun detectors and/or the rate gyro, and the magnetic-torquer only. The rate gyro measurement can be replaced by the low-pass filtered magnetometer measurements. The performance of the algorithm is demonstrated in a high-fidelity simulator.